public function getInput() { if (!class_exists('Koowa')) { return ''; } $selected = $this->value; $name = $this->name; $options = array(); $manager = KObjectManager::getInstance(); $translator = $manager->getObject('translator'); $helper = $manager->getObject('com://admin/docman.template.helper.select'); $options[] = $helper->option(array( 'label' => $translator->translate('JGLOBAL_USE_GLOBAL'), 'value' => 0)); foreach (array(5, 10, 15, 20, 25, 30, 50, 100) as $value) { $options[] = $helper->option(array('label' => $translator->translate('J' . $value), 'value' => $value)); } return $helper->optionlist(array( 'options' => $options, 'name' => $name, 'selected' => $selected )); }
public function install(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); // Output buffer is used as a guard against Joomla including ._ files when searching for adapters // See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html ob_start(); $installer = $app->getInstaller(); $installer->discover(); require_once $app->getPath() . '/administrator/components/com_installer/models/discover.php'; $model = new \InstallerModelDiscover(); $model->discover(); $results = $model->getItems(); $install = array(); foreach ($results as $result) { if ($result->element === 'com_extman') { array_unshift($install, $result->extension_id); } if ($result->type === 'component' && (in_array(substr($result->element, 4), $this->extension) || in_array($result->element, $this->extension))) { $install[] = $result->extension_id; } } ob_end_clean(); if (class_exists('Koowa') && !class_exists('ComExtmanDatabaseRowExtension')) { \KObjectManager::getInstance()->getObject('com://admin/extman.database.row.extension'); } $install = array_unique($install); foreach ($install as $extension_id) { try { $installer->discover_install($extension_id); } catch (\Exception $e) { $output->writeln("<info>Caught exception during install: " . $e->getMessage() . "</info>\n"); } } }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $this->check($input, $output); Bootstrapper::getApplication($this->target_dir); $catalogue = \KObjectManager::getInstance()->getObject('com://admin/koowa.translator')->getCatalogue(); $output->writeln($catalogue->getPrefix() . $catalogue->generateKey($input->getArgument('string'))); }
/** * Get the object configuration * * If no identifier is passed the object config of this object will be returned. Function recursively * resolves identifier aliases and returns the aliased identifier. * * @param string|object $identifier A valid identifier string or object implementing ObjectInterface * @return KObjectConfig */ public function getConfig($identifier = null) { if (isset($identifier)) { $result = $this->__object_manager->getIdentifier($identifier)->getConfig(); } else { $result = $this->__object_config; } return $result; }
/** * Gets the service identifier. * * If no identifier is passed the object identifier of this object will be returned. Function recursively * resolves identifier aliases and returns the aliased identifier. * * @param string|object $identifier The class identifier or identifier object * @return KObjectIdentifier */ public final function getIdentifier($identifier = null) { if (isset($identifier)) { $result = $this->__object_manager->getIdentifier($identifier); } else { $result = $this->__object_identifier; } return $result; }
public function __get($key) { if ($key === 'coupons') { if ($this->getDelegate()->has('coupon_ids')) { $manager = KObjectManager::getInstance(); $coupon_ids = $this->coupon_ids->toArray(); return $manager->getObject('com://admin/sales.model.coupons')->id($coupon_ids)->fetch(); } } return $this->getDelegate()->get($key); }
protected function getInput() { if (!class_exists('Koowa')) { return ''; } $value = $this->value; $el_name = $this->name; $multiple = (string) $this->element['multiple'] == 'true'; $deselect = (string) $this->element['deselect'] === 'true'; $id = isset($this->element['id']) ? (string) $this->element['element_id'] : 'docman_users_select2'; KObjectManager::getInstance()->getObject('translator')->load('com://admin/docman'); $view = KObjectManager::getInstance()->getObject('com://admin/docman.view.default'); $template = $view->getTemplate() ->addFilter('style') ->addFilter('script'); $attribs = array('class' => 'select2-listbox', 'id' => $id, 'multiple' => $multiple); $string = " <?= helper('bootstrap.load'); ?> <?= helper('listbox.users', array( 'prompt' => translate('All Users'), 'autocomplete' => true, 'name' => \$el_name, 'deselect' => \$deselect, 'selected' => \$value, 'attribs' => \$attribs )); ?>"; if(version_compare(JVERSION, '3.0', 'ge')) { $string .= " <script> kQuery(function($){ $('#s2id_<?= \$id ?>').show(); $('#<?= \$id ?>_chzn').remove(); }); </script> "; } return $template->loadString($string, 'php') ->render(array( 'el_name' => $el_name, 'value' => $value, 'deselect' => $deselect, 'attribs' => $attribs, 'id' => $id )); }
protected function getTemplateContent() { $pages = KObjectManager::getInstance()->getObject('com://admin/docman.model.pages') ->language('all')->fetch(); if (count($pages) === 0) { return " <?= helper('behavior.jquery'); ?> <?= helper('bootstrap.load'); ?> <div class=\"alert alert-error no_menu_items_layout\"> <h4><?= translate('No menu items found') ?></h4> <p><?= translate('Docman menu warning'); ?></p> <p><?= translate('Docman menu warning instruction'); ?></p> <p><a href=\"<?= JRoute::_('index.php?option=com_menus&view=items'); ?>\" class=\"btn btn-primary\"><?= translate('Go to menu manager') ?></a></p> </div> <? if(version_compare(JVERSION, '3.0', '<')): ?> <script> // Remove the label in Joomla 2.5 to make way for the big label kQuery(function(\$) { kQuery('.no_menu_items_layout').parents('li').find('label').remove(); }); </script> <? endif; ?> "; } $string = " <?= helper('bootstrap.load'); ?> <?= helper('listbox.pages', array( 'prompt' => translate('All pages'), 'name' => \$el_name, 'deselect' => \$deselect, 'selected' => \$value, 'attribs' => \$attribs, 'types' => \$types, 'options' => \$options )); ?>"; if(version_compare(JVERSION, '3.0', 'ge')) { $string .= " <script> kQuery(function($){ $('#s2id_<?= \$id ?>').show(); $('#<?= \$id ?>_chzn').remove(); }); </script> "; } return $string; }
protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $this->check($input, $output); require_once Util::buildTargetPath('libraries/koowa/libraries/koowa.php', $this->target_dir); require_once Util::buildTargetPath('configuration.php', $this->target_dir); \Koowa::getInstance(); $config = new \JConfig(); $secret = $config->secret; $user = $input->getArgument('username'); $token = \KObjectManager::getInstance()->getObject('http.token')->setSubject($user)->sign($secret); $output->writeln($token); }
public function postflight($type, $parent) { $manager = KObjectManager::getInstance(); $extension = $this->getExtension('plg_sales_offline'); $params = $extension->params; $gateway = $manager->getObject('com://admin/sales.model.gateways')->fetch()->find(array('factory_name' => $params->factory)); if ($gateway->isNew()) { $gateway->create(array('title' => $params->label, 'factory_name' => $params->factory, 'gateway_name' => $params->factory, 'element' => $extension->element, 'folder' => $extension->folder)); $gateway->save(); } $db = JFactory::getDbo(); $db->setQuery('UPDATE ' . $db->replacePrefix('#__extensions') . ' SET enabled = 1 WHERE name = ' . $db->quote('plg_sales_offline')); $db->execute(); }
/** * Create a stream * * If trigger_error flag is set exceptions will be catched and E_USER_WARNING raised using trigger_error(). If the * flag is not set and the stream cannot be created FALSE will be returned instead. * * @param string $url The stream url * @param string $mode The type of access required for this stream. (see Table 1 of the fopen() reference); * @param bool $trigger_error Raise errors using trigger_error. * @return KFilesystemStreamInterface|false */ public function createStream($url, $mode, $trigger_error = false) { try { $this->__stream = KObjectManager::getInstance()->getObject('filesystem.stream.factory')->createStream($url, $mode, $this->context); } catch (Exception $e) { //If this flag is set, you are responsible for raising errors using trigger_error() during //opening of the stream. If this flag is not set, you should not raise any errors. if ($trigger_error) { trigger_error($e->getMessage(), E_USER_WARNING); } return false; } return $this->__stream; }
public function postflight($type, $parent) { $manager = KObjectManager::getInstance(); $extension = $this->getExtension('plg_sales_paypalpro'); $params = $extension->params; $gateway = $manager->getObject('com://admin/sales.model.gateways')->fetch()->find(array('factory_name' => $params->factory)); if ($gateway->isNew()) { $gateway->create(array('title' => $params->label, 'factory_name' => $params->factory, 'gateway_name' => $params->factory, 'element' => $extension->element, 'folder' => $extension->folder, 'parameters' => array('username' => $params->username, 'password' => $params->password, 'partner' => $params->partner, 'vendor' => $params->vendor, 'tender' => $params->tender, 'sandbox' => (bool) $params->sandbox), 'fields' => array(array('editable' => true, 'element' => 'text', 'label' => 'Username', 'placeholder' => '', 'property' => 'username', 'required' => true), array('editable' => true, 'element' => 'password', 'label' => 'Password', 'placeholder' => '', 'property' => 'password', 'required' => true), array('editable' => true, 'element' => 'text', 'label' => 'Partner', 'placeholder' => '', 'property' => 'partner', 'required' => true), array('editable' => true, 'element' => 'text', 'label' => 'Vendor', 'placeholder' => '', 'property' => 'vendor', 'required' => true), array('editable' => true, 'element' => 'text', 'label' => 'Tender', 'placeholder' => '', 'property' => 'tender', 'required' => true), array('editable' => true, 'element' => 'boolean', 'label' => 'Sandbox', 'placeholder' => '', 'property' => 'sandbox', 'required' => true)), 'enabled' => 0)); $gateway->save(); } $db = JFactory::getDbo(); $db->setQuery('UPDATE ' . $db->replacePrefix('#__extensions') . ' SET enabled = 1 WHERE name = ' . $db->quote('plg_sales_paypalpro')); $db->execute(); }
/** * Logs in a given user to an application. * * @param string $username The username. * @param string $password The password. * @param object $application The application. * * @return bool True if login was successful, false otherwise. */ protected function _login($username, $password, $application) { // If we did receive the user credentials from the user, try to login if ($application->login(array('username' => $username, 'password' => $password)) !== true) { return false; } // If we have logged in succesfully, make sure to fullfil // Koowa's CSRF authenticator checks if the framework is loaded. if (class_exists('Koowa')) { $manager = KObjectManager::getInstance(); $request = $manager->getInstance()->getObject('com:koowa.dispatcher.request'); $user = $manager->getInstance()->getObject('user'); $token = $user->getSession()->getToken(); $request->setReferrer(JUri::root()); $request->getHeaders()->add(array('X-Xsrf-Token' => $token)); $request->getCookies()->add(array('csrf_token' => $token)); } return true; }
protected function generateUrl($path, array $parameters = array()) { $manager = KObjectManager::getInstance(); $url = $manager->getObject('lib:http.url', array('url' => JURI::base())); switch ($path) { case 'payment_done': $parameters = array_merge($parameters, array('view' => 'done')); break; case 'payum_capture_do': $parameters = array_merge($parameters, array('view' => 'capture')); break; case 'payum_notify_do': $parameters = array_merge($parameters, array('view' => 'notify')); break; } $route = $manager->getObject('lib:dispatcher.router.route', array('escape' => false))->setQuery($parameters); $route->scheme = $url->scheme; $route->host = $url->host; return $route->toString(); }
/** * Constructor * * Prevent creating instances of this class by making the constructor private * * @param array $config An optional array with configuration options. */ private final function __construct($config = array()) { //Initialize the root path if (isset($config['root_path'])) { $this->_root_path = $config['root_path']; } else { $this->_root_path = realpath($_SERVER['DOCUMENT_ROOT']); } //Initialize the base path if (isset($config['base_path'])) { $this->_base_path = $config['base_path']; } else { $this->_base_path = $this->_root_path; } //Initialize the vendor path if (isset($config['vendor_path'])) { $this->_vendor_path = $config['vendor_path']; } else { $this->_vendor_path = $this->_root_path . '/libraries/vendor'; } //Load the legacy functions require_once dirname(__FILE__) . '/legacy.php'; //Setup the loader require_once dirname(__FILE__) . '/class/loader.php'; if (!isset($config['class_loader'])) { $config['class_loader'] = KClassLoader::getInstance($config); } //Setup the factory $manager = KObjectManager::getInstance($config); //Register the component class locator $manager->getClassLoader()->registerLocator(new KClassLocatorComponent(array('namespaces' => array('\\' => $this->_base_path . '/components', 'Koowa' => dirname(dirname(__FILE__)))))); //Register the component object locator $manager->registerLocator('lib:object.locator.component'); //Register the composer class locator if (file_exists($this->getVendorPath())) { $manager->getClassLoader()->registerLocator(new KClassLocatorComposer(array('vendor_path' => $this->getVendorPath()))); } //Warm-up the stream factory $manager->getObject('lib:filesystem.stream.factory'); }
protected function getInput() { if (!class_exists('Koowa')) { return ''; } $value = $this->value; $el_name = $this->name; $multiple = (string) $this->element['multiple'] == 'true'; $deselect = $this->element['deselect'] === 'true'; $attribs = array(); if ($multiple) { $attribs['multiple'] = true; $attribs['size'] = $this->element['size'] ? $this->element['size'] : 5; } return KObjectManager::getInstance()->getObject('com://admin/docman.template.helper.listbox')->folders(array( 'name' => $el_name, 'selected' => $value )); }
protected function getInput() { if (!class_exists('Koowa')) { return ''; } $value = $this->value; $el_name = $this->name; KObjectManager::getInstance()->getObject('translator')->load('com://admin/docman'); $view = KObjectManager::getInstance()->getObject('com://admin/docman.view.default'); $template = $view->getTemplate() ->addFilter('style') ->addFilter('script'); $string = " <?= helper('bootstrap.load') ?> <?= helper('com://admin/docman.listbox.documents', array( 'name' => \$el_name, 'attribs' => array('id' => 'docman_document_select'), 'selected' => \$value, 'deselect' => false, 'autocomplete' => true, 'prompt' => translate('Search for a document'), 'value' => 'slug', 'label' => 'title' )) ?> "; return $template->loadString($string, 'php') ->render(array( 'el_name' => $el_name, 'value' => $value )); }
* * @copyright Copyright (C) 2007 - 2014 Johan Janssens and Timble CVBA. (http://www.timble.net) * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> * @link https://github.com/nooku/nooku-framework for the canonical source repository */ /** * Koowa Bootstrapping * * If KOOWA is defined assume it was already loaded and bootstrapped */ if (!defined('KOOWA')) { /** * Joomla Configuration */ require_once JPATH_CONFIGURATION . '/configuration.php'; $config = new JConfig(); /** * Joomla Version */ require_once JPATH_LIBRARIES . '/cms/version/version.php'; $version = new JVersion(); /** * Framework Bootstrapping */ require_once __DIR__ . '/code/libraries/koowa/libraries/koowa.php'; Koowa::getInstance(array('debug' => $config->debug, 'cache' => false, 'cache_namespace' => 'koowa-' . JPATH_BASE === JPATH_SITE ? 'site' : 'admin' . '-' . md5($config->secret), 'root_path' => JPATH_ROOT, 'base_path' => JPATH_BASE, 'vendor_path' => false)); /** * Component Bootstrapping */ KObjectManager::getInstance()->getObject('object.bootstrapper')->registerComponents(JPATH_LIBRARIES . '/koowa/components', 'koowa')->registerApplication('site', JPATH_SITE . '/components', JPATH_BASE === JPATH_SITE)->registerApplication('admin', JPATH_ADMINISTRATOR . '/components', JPATH_BASE == JPATH_ADMINISTRATOR)->bootstrap(); }
<?php /** * Todo - a Joomla example extension built with Nooku Framework. * * @package Todo * @copyright Copyright (C) 2011 - 2014 Timble CVBA. (http://www.timble.net) * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> * @link https://github.com/nooku/joomla-todo for the canonical source repository */ defined('_JEXEC') or die; if (class_exists('Koowa')) { //Catch exceptions before Joomla does (JApplication::dispatch()) try { echo KObjectManager::getInstance()->getObject('mod://site/todo_tasks.html')->module($module)->attribs($attribs)->render(); } catch (Exception $exception) { KObjectManager::getInstance()->getObject('exception.handler')->handleException($exception); } }
public function onAfterRoute() { $app = JFactory::getApplication(); $input = $app->input; $option = $input->getCmd('option', ''); if (!class_exists('Koowa') || !class_exists('KObjectManager') || !$app->isSite() || $option !== 'com_docman' ) { return; } $task = $input->getCmd('task', ''); $id = $input->getInt('gid', 0); if (empty($task) && preg_match('#(doc_details|doc_download|cat_view)\/([0-9]+)#i', (string)JFactory::getURI(), $matches)) { $task = $matches[1]; $id = $matches[2]; } if (!in_array($task, array('doc_details', 'doc_download', 'cat_view'))) { return; } $itemid = $input->getInt('Itemid', 0); $url = null; if (!$app->getMenu()->getItem($itemid)) { $itemid = 0; } if ($task === 'doc_download' || $task === 'doc_details') { $document = KObjectManager::getInstance()->getObject('com://site/docman.model.documents') ->enabled(1) ->status('published') // Also need to redirect links for registered users //->access(KObjectManager::getInstance()->getObject('user')->getRoles()) ->page('all') ->id($id) ->fetch(); if (!$document->isNew()) { $view = $task === 'doc_download' ? 'download' : 'document'; $url = sprintf('index.php?option=com_docman&view=%s&category_slug=%s&alias=%s&Itemid=%d', $view, $document->category_slug, $document->alias, $itemid ? $itemid : $document->itemid); } } elseif ($task === 'cat_view') { $category = KObjectManager::getInstance()->getObject('com://site/docman.model.categories') ->enabled(1) // Also need to redirect links for registered users //->access(KObjectManager::getInstance()->getObject('user')->getRoles()) ->page('all') ->id($id) ->fetch(); if (!$category->isNew()) { $url = sprintf('index.php?option=com_docman&view=list&slug=%s&Itemid=%d', $category->slug, $itemid ? $itemid : $category->itemid); } } if ($url) { if (version_compare(JVERSION, '3.2', '<')) { $app->redirect(JRoute::_($url, false), '', 'message', true); } else { $app->redirect(JRoute::_($url, false), true); } } }
protected function getInput() { if (!class_exists('Koowa')) { return ''; } $value = $this->value; $el_name = $this->name; $key_field = (string) $this->element['key_field']; $multiple = (string) $this->element['multiple'] == 'true'; $deselect = (string) $this->element['deselect'] === 'true'; $id = isset($this->element['id']) ? (string) $this->element['element_id'] : 'docman_categories_select2'; $pages = isset($this->element['pages']) ? (string) $this->element['pages'] : null; KObjectManager::getInstance()->getObject('translator')->load('com://admin/docman'); $view = KObjectManager::getInstance()->getObject('com://admin/docman.view.default.html'); $template = $view->getTemplate() ->addFilter('style') ->addFilter('script'); $attribs = array(); if ($multiple) { $attribs['multiple'] = true; $attribs['size'] = $this->element['size'] ? $this->element['size'] : 5; } $value_field = $key_field ? $key_field : 'slug'; $string = " <?= helper('bootstrap.load'); ?> <?= helper('com://admin/docman.listbox.categories', array( 'name' => \$el_name, 'value' => \$value_field, 'deselect' => \$deselect, 'selected' => \$value, 'filter' => array( 'page' => \$pages ), 'attribs' => array_merge(\$attribs, array( 'id' => \$id, 'data-placeholder' => translate('All Categories'))) )); ?>"; if(version_compare(JVERSION, '3.0', 'ge')) { $string .= " <script> kQuery(function($){ $('#s2id_<?= \$id ?>').show(); $('#<?= \$id ?>_chzn').remove(); }); </script> "; } return $template->loadString($string, 'php') ->render(array( 'el_name' => $el_name, 'value' => $value, 'value_field' => $value_field, 'deselect' => $deselect, 'attribs' => $attribs, 'id' => $id, 'pages' => $pages )); }
protected function _migrateMenuItems() { $id = JComponentHelper::getComponent('com_docman')->id; $table = KObjectManager::getInstance()->getObject('com://admin/docman.database.table.menus', array('name' => 'menu')); $items = $table->select(array('component_id' => $id)); $config = $this->getObject('com://admin/docman.model.entity.config'); foreach ($items as $item) { if ($item->menutype === 'main') { continue; } parse_str(str_replace('index.php?', '', $item->link), $query); $view = isset($query['view']) ? $query['view'] : null; if ($view === 'documents') { // documents view got renamed to filteredlist in RC1 $item->link = str_replace('view=documents', 'view=filteredlist', $item->link); $view = 'filteredlist'; } elseif ($view === 'category' || $view === 'categories') { // category and categories view got consolidated into list view in beta3 $slug = $view === 'categories' ? '' : $query['slug']; $item->link = 'index.php?option=com_docman&view=list&slug=' . $slug; if (!empty($item->params)) { $params = json_decode($item->params); $params->show_subcategories = '1'; if ($view === 'categories') { $params->sort_documents = 'title'; } unset($params->show_document_count); $item->params = json_encode($params); } $view = 'list'; } if (in_array($view, array('document', 'filteredlist', 'list')) && $this->old_version) { $params = json_decode($item->params); // preview_with_gdocs and days_for_new got moved into menu items in 2.0.0RC1 if (version_compare($this->old_version, '2.0.0RC1', '<')) { $params->preview_with_gdocs = $config->preview_with_gdocs; $params->days_for_new = $config->days_for_new; } // New parameters were added in 2.0.0 if (version_compare($this->old_version, '2.0.0', '<')) { $params->show_document_popular = 1; $params->show_document_hits = 1; $params->hits_for_popular = 100; $params->can_edit_own = ''; $params->can_delete_own = ''; if ($view === 'list') { $params->show_categories_header = '1'; $params->show_documents_header = '1'; } } $item->params = json_encode($params); } $item->save(); } }
public function uninstall($installer) { $db = JFactory::getDBO(); $query = sprintf('SHOW TABLES LIKE %s', $db->quote($db->replacePrefix('#__extman_extensions'))); if ($db->setQuery($query)->loadResult()) { // Pre-cache uninstall tracking code since we are gonna get rid of the framework if (class_exists('Koowa')) { $params = JComponentHelper::getParams('com_extman'); $uuid = $params->get('joomlatools_user_id'); $controller = KObjectManager::getInstance()->getObject('com://admin/extman.controller.extension')->view('extension')->layout('uninstall')->event('uninstall'); $extension = $controller->read(); $extension->name = 'EXTman'; $extension->joomlatools_user_id = $uuid; $extension->version = (string) $this->helper->manifest->version; echo $controller->render(); } $db->setQuery("SELECT name FROM #__extman_extensions WHERE parent_id = 0 AND identifier <> 'com:extman'"); $results = $db->loadColumn(); if (count($results)) { $extension = count($results) == 1 ? sprintf('the <strong>%s</strong> extension by Joomlatools installed', $results[0]) : sprintf('%d Joomlatools extensions installed', count($results)); JFactory::getApplication()->enqueueMessage(sprintf("You have {$extension}. EXTman is needed for Joomlatools extensions to work properly. These extensions will not work until you re-install EXTman. EXTman database tables are not deleted to make sure your site still works if you install it again.", JRoute::_('index.php?option=com_extman')), 'error'); } else { $tables = array('#__extman_extensions', '#__extman_dependencies'); foreach ($tables as $table) { $db->setQuery('DROP TABLE IF EXISTS ' . $db->replacePrefix($table)); $db->query(); } } } $this->helper->uninstallFramework(); }
public function install(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); $db = \JFactory::getDbo(); // Output buffer is used as a guard against Joomla including ._ files when searching for adapters // See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html ob_start(); $installer = $app->getInstaller(); $installer->discover(); require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/discover.php'; $model = new \InstallerModelDiscover(); $model->discover(); $results = $model->getItems(); ob_end_clean(); $install = array(); $plugins = array(); foreach ($this->extensions as $extension) { foreach ($results as $result) { $included = false; if (in_array($result->element, array('com_extman', 'koowa')) && ($extension == 'all' || $extension == $result->element)) { array_unshift($install, $result); $included = true; } elseif ($extension == 'all' || in_array($extension, array($result->element, substr($result->element, 4)))) { $install[] = $result; $included = true; } if ($result->type == 'plugin' && $included) { $plugins[] = $result->extension_id; } if ($included && $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Queued {$result->name} for installation."); } } } foreach ($install as $extension) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Installing {$extension->element} .."); } try { $installer->discover_install($extension->extension_id); } catch (\Exception $e) { $output->writeln("<info>Caught exception whilst installing {$extension->type} {$extension->element}: " . $e->getMessage() . "</info>\n"); } if (in_array($extension->extension_id, $plugins)) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Enabling plugin `{$extension->element}` (ID #{$extension->extension_id}) .."); } $sql = "UPDATE `#__extensions` SET `enabled` = 1 WHERE `extension_id` = '{$extension->extension_id}'"; $db->setQuery($sql); $db->execute(); switch ($extension->element) { case 'com_extman': if (class_exists('Koowa') && !class_exists('ComExtmanDatabaseRowExtension')) { \KObjectManager::getInstance()->getObject('com://admin/extman.database.row.extension'); } break; case 'koowa': $path = JPATH_PLUGINS . '/system/koowa/koowa.php'; if (!file_exists($path)) { return; } require_once $path; if (class_exists('\\PlgSystemKoowa')) { $dispatcher = \JEventDispatcher::getInstance(); new \PlgSystemKoowa($dispatcher, (array) \JPLuginHelper::getPLugin('system', 'koowa')); } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln("Initialised new PlgSystemKoowa instance"); } break; } } } }
protected function getInput() { if (!class_exists('Koowa')) { return ''; } $value = $this->value; $el_name = $this->name; $multiple = (string) $this->element['multiple'] == 'true'; $deselect = (string) $this->element['deselect'] === 'true'; $id = isset($this->element['id']) ? (string) $this->element['element_id'] : 'docman_page_categories_select2'; $tree = isset($this->element['tree']) && $this->element['tree'] == 'true' ? true : false; KObjectManager::getInstance()->getObject('translator')->load('com://admin/docman'); $view = KObjectManager::getInstance()->getObject('com://admin/docman.view.default'); $template = $view->getTemplate() ->addFilter('style') ->addFilter('script'); $attribs = array('class' => 'select2-listbox', 'id' => $id, 'multiple' => $multiple); // Grab selected page. $page = @$this->form->getValue("params")->page; if (empty($page)) $page = 'all'; $string = " <?= helper('bootstrap.load'); ?> <?= helper('listbox.pagecategories', array( 'prompt' => translate('All Categories'), 'page' => \$page, 'select2' => true, 'tree' => \$tree, 'name' => \$el_name, 'deselect' => \$deselect, 'selected' => \$value, 'attribs' => \$attribs )); ?>"; if(version_compare(JVERSION, '3.0', 'ge')) { $string .= " <script> kQuery(function($){ $('#s2id_<?= \$id ?>').show(); $('#<?= \$id ?>_chzn').remove(); }); </script> "; } $url = JRoute::_('index.php?option=com_docman&view=categories&format=json', false); $string .= " <script> kQuery(function($){ $('#docman_page_select2').change(function(e) { var url = e.val ? '$url' + '&page=' + e.val : '$url'; $.ajax(url, { success: function(data) { var select = $('#$id'); select.empty(); $.each(data.entities, function(idx, el) { select.append('<option value=\"'+el.id+'\">'+el.hierarchy_title+'</option>'); }); // Reset selection select.select2('val', ''); } }); }); }); </script>"; return $template->loadString($string, 'php') ->render(array( 'tree' => $tree, 'page' => $page, 'el_name' => $el_name, 'value' => $value, 'deselect' => $deselect, 'attribs' => $attribs, 'id' => $id )); }
/** * Returns the model * * @return KModelAbstract */ protected function getModel() { if (!$this->model instanceof KModelInterface) { if (strpos($this->model, '.') === false) { $this->model = 'com://admin/' . $this->package . '.model.' . $this->model; } $this->model = KObjectManager::getInstance()->getObject($this->model); } return $this->model; }
/** * Turns an entity into a finder item * * @param KModelEntityInterface $entity * @return object */ protected function getFinderItem(KModelEntityInterface $entity) { if (!$entity->itemid) { $entity->itemid = $this->getModel()->findPage($entity); } $item = parent::getFinderItem($entity); // Add language if ($entity->itemid) { $menu = KObjectManager::getInstance()->getObject('com://admin/docman.model.pages') ->language('all')->id($entity->itemid)->fetch(); if ($menu->language) { $item->language = $menu->language; } } // Add the category taxonomy data. if (!empty($item->category_title)) { $category_state = isset($item->category_enabled) ? $item->category_enabled : 1; $category_access = isset($item->category_access) ? $item->category_access : 1; $item->state = min($item->enabled, $category_state); $item->access = max($item->access, $category_access); $item->addTaxonomy('Category', $item->category_title, $category_state, $category_access); } return $item; }
/** * Exception event handler * * @param KEventException $event */ public function onException(KEventException $event) { KObjectManager::getInstance()->getObject('com:koowa.dispatcher.http')->fail($event); return true; }
public function postflight($type, $installer) { if ($type === 'update') { $this->_updateRedirectPlugin($installer); } $extension_id = ComExtmanModelEntityExtension::getExtensionId(array( 'type' => 'component', 'element' => 'com_'.$this->component )); $controller = KObjectManager::getInstance()->getObject('com://admin/extman.controller.extension') ->view('extension') ->layout('success') ->event($type === 'update' ? 'update' : 'install'); $controller->add(array( 'source' => $installer->getParent()->getPath('source'), 'manifest' => $installer->getParent()->getPath('manifest'), 'joomla_extension_id' => $extension_id, 'install_method' => $type, 'event' => $type === 'update' ? 'update' : 'install' )); echo $controller->render(); }
/** * Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * * @param string $keyword Target search string * @param string $type matching option, exact|any|all * @param string $order ordering option, newest|oldest|popular|alpha|category * @param null $areas An array if the search it to be restricted to areas, null if search all * * @return array results */ public function onContentSearch($keyword, $type='', $order='', $areas=null) { if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $keyword = trim($keyword); if (empty($keyword)) { return array(); } $return = array(); $pages = KObjectManager::getInstance()->getObject('com://admin/docman.model.pages')->fetch(); if (count($pages)) { $limit = $this->params->def('search_limit', 50); $order_map = array( 'default' => array('tbl.title', 'ASC'), 'oldest' => array('tbl.created_on', 'ASC'), 'newest' => array('tbl.created_on', 'DESC'), 'category' => array('category_title', 'ASC'), 'popular' => array('tbl.hits', 'DESC') ); if (!array_key_exists($order, $order_map)) { $order = 'default'; } list($sort, $direction) = $order_map[$order]; $user = KObjectManager::getInstance()->getObject('user'); $model = KObjectManager::getInstance()->getObject('com://admin/docman.model.documents'); $model->enabled(1) ->status('published') ->current_user($user->getId()) ->access($user->getRoles()) ->page('all') ->search($keyword) ->search_by($type) ->limit($limit) ->sort($sort) ->direction($direction); $list = $model->fetch(); if (!count($list)) { return array(); } $return = array(); foreach ($list as $item) { if (!$item->itemid || !searchHelper::checkNoHTML($item, $keyword, array('title', 'description'))) { continue; } $entity = new stdClass(); $entity->created = $item->created_on; $entity->href = JRoute::_(sprintf('index.php?option=com_docman&view=document&alias=%s&category_slug=%s&Itemid=%d', $item->alias, $item->category->slug, $item->itemid)); $entity->browsernav = ''; $entity->title = $item->title; $entity->section = ''; $entity->text = $item->description; $return[] = $entity; } } return $return; }