Пример #1
0
 /**
  * Configurator
  *
  * @param KConfig $config Property Configuration 
  * 
  * @return void
  */
 public function setConfig(KConfig $config)
 {
     $identifier = $config->description->getRepository()->getIdentifier();
     if ($config->parent) {
         $this->_parent = KService::getIdentifier($config->parent);
         //adopt the child application
         if (!$this->_parent->application) {
             $this->_parent->application = $identifier->application;
         }
     }
     parent::setConfig($config);
     if ($config->child) {
         if (strpos($config->child, '.') === false) {
             $identifier = clone $this->_parent;
             $identifier->name = $config->child;
             $config->child = $identifier;
         }
         $this->_child = KService::getIdentifier($config->child);
         //adopt the parent application
         if (!$this->_child->application) {
             $this->_child->application = $identifier->application;
         }
     }
     $this->_parent_key = $config->parent_key;
     if (is_array($config->query)) {
         $config->query = new KConfig($config->query);
     }
     $this->_query_filters = $config->query;
 }
Пример #2
0
 protected function _beforeDispatch(KCommandContext $context)
 {
     if ($this->getRequest()->container === 'docman-files') {
         KService::setConfig('com://admin/files.controller.file', array('behaviors' => array('com://admin/docman.controller.behavior.file')));
         KService::setConfig('com://admin/files.controller.folder', array('behaviors' => array('com://admin/docman.controller.behavior.folder')));
         KService::setAlias('com://admin/files.model.containers', 'com://admin/docman.model.containers');
         KService::setAlias('com://site/files.model.containers', 'com://admin/docman.model.containers');
     }
     // Use our own ACL instead of com_files'
     KService::setAlias('com://admin/files.controller.behavior.executable', 'com://admin/docman.controller.behavior.executable');
     if ($this->getRequest()->routed) {
         $app = JFactory::getApplication();
         $behavior = 'com://admin/docman.controller.behavior.cacheable';
         // If the upload_folder parameter is set, we change the container path so results are different
         if ($app->isSite() && $app->getMenu()->getActive()->params->get('upload_folder')) {
             $behavior = $this->getService($behavior, array('only_clear' => true));
         }
         foreach (array('file', 'folder', 'node', 'thumbnail') as $name) {
             KService::setConfig('com://admin/files.controller.' . $name, array('behaviors' => array($behavior)));
         }
         if (!in_array($this->getRequest()->container, array('docman-files', 'docman-icons', 'docman-images'))) {
             $this->getRequest()->container = 'docman-files';
         }
         if ($this->getRequest()->container === 'docman-icons') {
             KService::setConfig('com://admin/files.controller.file', array('behaviors' => array('com://admin/docman.controller.behavior.icon')));
         }
         // Work-around the bug here: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=28249
         JFactory::getSession()->set('com_docman.fix.the.session.bug', microtime(true));
         $context->result = $this->getService('com://admin/files.dispatcher', array('request' => array('container' => $this->getRequest()->container)))->dispatch();
         return false;
     }
 }
Пример #3
0
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if ($text) {
         $rows = array();
         $rowset = KService::get('com://admin/kutafuta.model.terms')->type($phrase)->search($text)->getList();
         foreach ($rowset as $row) {
             // We have table and row.
             // Row is always multiple but we check non the less.
             $parts = explode('_', $row->table);
             $data = KService::get('com://site/' . $parts[0] . '.model.' . KInflector::pluralize($parts[1]))->id($row->row)->getItem();
             if (empty($data->id)) {
                 continue;
             }
             $result = new stdClass();
             $result->title = $data->title;
             $result->metadesc = $data->meta_description;
             $result->metakey = $data->meta_keywords;
             $result->created = $data->created_on;
             $result->text = $data->introtext . $data->fulltext;
             $result->href = 'index.php?option=com_' . $parts[0] . '&view=' . KInflector::singularize($parts[1]) . '&id=' . $row->row;
             $rows[] = $result;
         }
         return $rows;
     }
 }
Пример #4
0
 /** 
  * Constructor.
  * 
  * @param mixed $dispatcher A dispatcher
  * @param array $config     An optional KConfig object with configuration options.
  * 
  * @return void
  */
 public function __construct($dispatcher = null, $config = array())
 {
     $config = new KConfig($config);
     parent::__construct($config);
     $this->_name = $config->name;
     KService::get('plg:contentfilter.chain')->addFilter($this);
 }
Пример #5
0
 /**
  * @param KCommandContext $context
  */
 public function updateIndex(KCommandContext $context)
 {
     $filter = KService::get('koowa:filter.string');
     $table = $context->data->getTable()->getName();
     $row = $context->data->id;
     $this->_beforeTableDelete($context);
     if ($context->data->enabled) {
         if ($context->data->isTranslatable()) {
             if (!$context->data->translated && !$context->data->original) {
                 return;
             }
         }
         // Saving the title.
         $this->getService('com://admin/kutafuta.database.row.term')->setData(array('table' => $table, 'row' => $row, 'value' => $context->data->title, 'lang' => substr(JFactory::getLanguage()->getTag(), 0, 2)))->save();
         // Saving the elements of elementable, only if the value is a string.
         if ($context->data->isElementable()) {
             foreach ($context->data->getElements() as $key => $value) {
                 $val = $context->data->{$value->slug};
                 if ($filter->validate(strip_tags($val)) && !empty($val) && !is_numeric($val)) {
                     $this->getService('com://admin/kutafuta.database.row.term')->setData(array('table' => $table, 'row' => $row, 'value' => trim(strip_tags($val)), 'lang' => substr(JFactory::getLanguage()->getTag(), 0, 2)))->save();
                 }
             }
         }
     }
 }
Пример #6
0
 /**
  * Authenticates a user using oauth_token,oauth_secret
  *
  * 
  * @param   array   $credentials Array holding the user credentials
  * @param   array   $options     Array of extra options
  * @param   object  $response    Authentication response object
  * @return  boolean
  * @since 1.5
  */
 public function onAuthenticate(&$credentials, $options, &$response)
 {
     if (isset($credentials['username']) && isset($credentials['password'])) {
         return;
     }
     if (isset($credentials['oauth_token']) && isset($credentials['oauth_handler'])) {
         try {
             extract($credentials, EXTR_SKIP);
             //if oatuh secret not set then set it to null
             if (empty($oauth_secret)) {
                 $oauth_secret = '';
             }
             //lets get the api
             $api = ComConnectHelperApi::getApi($oauth_handler);
             $api->setToken($oauth_token, $oauth_secret);
             //if we can get the logged in user then
             //the user is authenticated
             if ($profile_id = $api->getUser()->id) {
                 //lets find a valid sesison
                 //lets be strict and make sure all the values match
                 $session = KService::get('repos://site/connect.session')->find(array('owner.type' => 'com:people.domain.entity.person', 'profileId' => $profile_id, 'tokenKey' => $oauth_token, 'api' => $oauth_handler));
                 if ($session) {
                     $response->status = JAUTHENTICATE_STATUS_SUCCESS;
                     $response->username = $session->owner->username;
                     $response->password = '******';
                     $response->fullname = ' ';
                 }
             }
         } catch (Exception $e) {
             //ignore any exception
         }
     }
 }
Пример #7
0
 /**
  * Creates a custom form element.
  *
  * @param mixed $parent
  */
 public function __construct($parent = null)
 {
     parent::__construct($parent);
     $this->_template = KService::get('com:base.template.default');
     $this->_template->addFilter(array('shorttag', 'alias'));
     $this->_template->getFilter('alias')->append(array('@route(' => 'JRoute::_(', '@html(\'' => '$this->renderHelper(\'com:base.template.helper.html.'));
 }
Пример #8
0
 /**
  * Filter a value.
  *
  * @param string The text to filter
  *
  * @return string
  */
 public function filter($text)
 {
     preg_match_all('/(pages|topics|photos|todos|notes)\\/([0-9]+)[-]?/', $text, $matches);
     $ids = $matches[2];
     foreach ($ids as $id) {
         $id = (int) $id;
         $medium = KService::get('repos:medium.medium')->getQuery()->disableChain()->id($id)->fetch();
         if (isset($medium->id) && $medium->authorize('access')) {
             if ($medium->getRepository()->hasBehavior('portraitable')) {
                 $caption = htmlspecialchars($medium->title, ENT_QUOTES, 'UTF-8');
                 $pattern = '/((?<!=\\")[http]+[s]?:\\/\\/[^<>\\s]+)\\/photos\\/' . $medium->id . '[-\\w\\-]*/';
                 $text = preg_replace($pattern, '<a data-trigger="MediaViewer" href="' . $medium->getPortraitURL('original') . '" title="' . $caption . '" >' . '<img alt="' . $caption . '" src="' . $medium->getPortraitURL('medium') . '" />' . '</a> ', $text);
             } else {
                 $pattern = '/((?<!=\\")[http]+[s]?:\\/\\/[^<>\\s]+)\\/pages\\/' . $medium->id . '[-\\w\\-]*/';
                 $template = '<div class="alert alert-block alert-success">';
                 if ($medium->title) {
                     $template .= '<h4><a href="' . JRoute::_($medium->getURL()) . '">' . $medium->title . '</a></h4>';
                 }
                 if ($medium->excerpt) {
                     $template .= '<p>' . $medium->excerpt . '</p>';
                 }
                 $template .= '</div>';
                 $text = preg_replace($pattern, $template, $text);
             }
         }
     }
     return $text;
 }
Пример #9
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     $timeThen = microtime(true);
     //converting the old boards as hashtags
     $boards = dbfetch('SELECT `id`, `alias` FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\' ');
     foreach ($boards as $board) {
         $terms = explode('-', $board['alias']);
         foreach ($terms as $index => $value) {
             if (strlen($value) < 3) {
                 unset($terms[$index]);
             }
         }
         $topics = KService::get('com://site/topics.domain.entity.topic')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $board['id'])->fetchSet();
         foreach ($topics as $topic) {
             foreach ($terms as $term) {
                 if (strlen($term) > 3) {
                     dboutput($term . ', ');
                     $topic->set('description', $topic->description . ' #' . trim($term))->addHashtag($term)->save();
                 }
             }
         }
     }
     dbexec('UPDATE #__anahita_nodes SET `parent_id` = 0 WHERE `type` LIKE \'%com:topics.domain.entity.topic\'');
     dbexec('DELETE FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\'');
     dbexec('DELETE FROM #__anahita_edges WHERE `node_b_type` LIKE \'%com:topics.domain.entity.board\'');
     dbexec('DROP TABLE #__topics_boards');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Пример #10
0
function plgSearchEvents($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchEventsAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'events');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $events = KService::get('com://admin/calendar.model.events')->sort('tbl.start_date')->direction('ASC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($events as $event) {
        if (searchHelper::checkNoHTML($event, $text, array('title', 'description'))) {
            $event->text = $event->description;
            $event->origin = 'events';
            $event->href = 'index.php?option=com_calendar&view=event&id=' . $event->id . '&slug=' . $event->slug;
            $event->section = JText::_('Events');
            $return[] = $event->getData();
        }
    }
    return $return;
}
Пример #11
0
    protected function getInput()
    {
        // Load the modal behavior script.
        JHtml::_('behavior.modal', 'a.modal');
        // Build the script.
        $script = array();
        $script[] = '	function jSelectArticle_' . $this->id . '(id, title, catid, object) {';
        $script[] = '		document.id("' . $this->id . '_id").value = id;';
        $script[] = '		document.id("' . $this->id . '_name").value = title;';
        $script[] = '		SqueezeBox.close();';
        $script[] = '	}';
        // Add the script to the document head.
        JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
        // Setup variables for display.
        $html = array();
        $link = 'index.php?option=com_articles&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;function=jSelectArticle_' . $this->id;
        $title = KService::get('com://site/articles.model.articles')->id($this->value)->getItem()->title;
        $html[] = '<span class="input-append">';
        $html[] = '<input type="text" class="inoutbox input=medium" id="' . $this->id . '_name" value="' . $title . '" readonly="readonly" disabled="disabled" size="40" placeholder="' . JText::_('COM_ARTICLES_SELECT_AN_ITEM') . '" /><a class="btn btn-primary modal" href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-list icon-white"></i>
' . JText::_('Select') . '</a>';
        // The active article id field.
        if (0 == (int) $this->value) {
            $value = '';
        } else {
            $value = (int) $this->value;
        }
        // class='required' for client side validation
        $class = '';
        if ($this->required) {
            $class = ' class="required modal-value"';
        }
        $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
        return implode("\n", $html);
    }
Пример #12
0
 /**
  * Called when migrating up.
  */
 public function up()
 {
     $timeThen = microtime(true);
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%ComBaseDomainEntityComment%\' AND `parent_type` = \'com:todos.domain.entity.milestone\' ');
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.milestone\' ');
     dbexec('DELETE FROM #__edges WHERE `node_b_type` LIKE \'%com:todos.domain.entity.milestone\' ');
     dbexec('DROP TABLE #__todos_milestones');
     //clearing todolists from the data
     $todolists = dbfetch('SELECT `id`, `parent_id`, `alias` FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' ');
     foreach ($todolists as $todolist) {
         $terms = explode('-', $todolist['alias']);
         foreach ($terms as $index => $value) {
             if (strlen($value) < 3) {
                 unset($terms[$index]);
             }
         }
         $todos = KService::get('com://site/todos.domain.entity.todo')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $todolist['id'])->fetchSet();
         foreach ($todos as $todo) {
             foreach ($terms as $term) {
                 if (strlen($term) > 3) {
                     dboutput($term . ', ');
                     $todo->set('parent_id', 0)->set('description', $todo->description . ' #' . trim($term))->addHashtag($term)->save();
                 }
             }
         }
     }
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' ');
     //clear stories
     dbexec('DELETE FROM #__nodes WHERE `story_object_type` = \'com:todos.domain.entity.todolist\' OR `story_object_type` = \'com:todos.domain.entity.milestone\' ');
     dbexec('DROP TABLE #__todos_todolists');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Пример #13
0
 function fetchElement($name, $value, &$node = null, $control_name = null)
 {
     $el_name = $control_name ? $control_name . '[' . $name . ']' : $name;
     JHtml::_('behavior.modal');
     $html = KService::get('com://admin/fileman.template.helper.modal')->select(array('name' => $el_name, 'id' => 'fileman-file-link-name', 'value' => $value, 'link' => JRoute::_('index.php?option=com_fileman&view=files&layout=select&tmpl=component')));
     return $html;
 }
Пример #14
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $key_field = $node->attributes('key_field');
     $attribs = array();
     $el_name = $control_name . '[' . $name . ']';
     return KService::get('com://admin/news.template.helper.listbox')->category(array('name' => $el_name, 'value' => $key_field ? $key_field : 'id', 'deselect' => true, 'showroot' => false, 'selected' => $value, 'attribs' => $attribs));
 }
Пример #15
0
 /**
  * @param KCommandContext $context
  */
 public function _actionCopy(KCommandContext $context)
 {
     foreach (KRequest::get('get.id', 'raw') as $item_id) {
         $this->count = 1;
         $items = array();
         $languages = JLanguageHelper::getLanguages();
         $model_identifier = clone $context->caller->getIdentifier();
         $model_identifier->path = array('model');
         $model_identifier->name = KInflector::pluralize($model_identifier->name);
         $isTranslatable = KService::get($model_identifier)->getTable()->hasBehavior('translatable');
         if ($isTranslatable) {
             foreach ($languages as $language) {
                 JFactory::getLanguage()->setLanguage($language->lang_code);
                 $item = $this->getService($model_identifier)->id($item_id)->getItem();
                 if ($item->original) {
                     $this->original_language = $language->lang_code;
                     $original = $item;
                 } else {
                     $items[$language->lang_code] = $item;
                 }
             }
         }
         JFactory::getLanguage()->setLanguage($this->original_language);
         $id = $this->_copyOriginal($original);
         if ($isTranslatable) {
             $this->_updateLanguages($id, $items);
         }
     }
 }
Пример #16
0
function plgSearchArticles($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchArticlesAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'articles');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $articles = KService::get('com://admin/news.model.articles')->sort('tbl.created_on')->direction('DESC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($articles as $article) {
        if (searchHelper::checkNoHTML($article, $text, array('title', 'text'))) {
            $article->origin = 'articles';
            $article->href = 'index.php?option=com_news&view=article&id=' . $article->id . '&slug=' . $article->slug;
            $article->section = $article->category_title;
            $return[] = $article->getData();
        }
    }
    return $return;
}
Пример #17
0
 public function __construct($subject, $config = array())
 {
     // Turn off E_STRICT errors for now
     error_reporting(error_reporting() & ~E_STRICT);
     // Check if database type is MySQLi
     if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
         if (JFactory::getApplication()->getName() === 'administrator') {
             $string = version_compare(JVERSION, '1.6', '<') ? 'mysqli' : 'MySQLi';
             $link = JRoute::_('index.php?option=com_config');
             $error = 'In order to use Joomlatools framework, your database type in Global Configuration should be set to <strong>%1$s</strong>. Please go to <a href="%2$s">Global Configuration</a> and in the \'Server\' tab change your Database Type to <strong>%1$s</strong>.';
             JError::raiseWarning(0, sprintf(JText::_($error), $string, $link));
         }
         return;
     }
     // Set pcre.backtrack_limit to a larger value
     // See: https://bugs.php.net/bug.php?id=40846
     if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
         @ini_set('pcre.backtrack_limit', 1000000);
     }
     //Set constants
     define('KDEBUG', JDEBUG);
     //Set path definitions
     define('JPATH_FILES', JPATH_ROOT);
     define('JPATH_IMAGES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'images');
     //Set exception handler
     set_exception_handler(array($this, 'exceptionHandler'));
     // Koowa : setup
     require_once JPATH_LIBRARIES . '/koowa/koowa.php';
     Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
     KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
     KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
     KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
     KServiceIdentifier::setApplication('site', JPATH_SITE);
     KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
     KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
     KService::setAlias('translator', 'com:default.translator');
     //Setup the request
     if (JFactory::getApplication()->getName() !== 'site') {
         KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
     }
     //Load the koowa plugins
     JPluginHelper::importPlugin('koowa', null, true);
     //Bugfix : Set offset accoording to user's timezone
     if (!JFactory::getUser()->guest) {
         if ($offset = JFactory::getUser()->getParam('timezone')) {
             if (version_compare(JVERSION, '3.0', '>=')) {
                 JFactory::getConfig()->set('offset', $offset);
             } else {
                 JFactory::getConfig()->setValue('config.offset', $offset);
             }
         }
     }
     // Load language files for the framework
     KService::get('com:default.translator')->loadLanguageFiles();
     parent::__construct($subject, $config);
 }
Пример #18
0
 public function _actionBrowse($context)
 {
     //     $session = Kservice::get('com://site/people.controller.session');
     //     $viewer = get_viewer();
     //     $session = JFactory::getSession();
     $this->categories = KService::get('repos://site/forums.category')->getQuery()->order('ordering')->fetchSet();
     parent::_actionBrowse($context);
 }
Пример #19
0
 function display($tpl = null)
 {
     global $option;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $client = JRequest::getWord('client', 'site');
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $lists = array();
     $row =& JTable::getInstance('plugin');
     // load the row from the db table
     $row->load($cid[0]);
     // fail if checked out not by 'me'
     if ($row->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The plugin'), $row->title);
         $this->setRedirect('index.php?option=' . $option . '&client=' . $client, $msg, 'error');
         return false;
     }
     if ($client == 'admin') {
         $where = "client_id='1'";
     } else {
         $where = "client_id='0'";
     }
     // get list of groups
     if ($row->access == 99 || $row->client_id == 1) {
         $lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />';
     } else {
         // build the html select list for the group access
         $lists['access'] = JHTML::_('list.accesslevel', $row);
     }
     if ($cid[0]) {
         $row->checkout($user->get('id'));
         if ($row->ordering > -10000 && $row->ordering < 10000) {
             // build the html select list for ordering
             $query = 'SELECT ordering AS value, name AS text' . ' FROM #__plugins' . ' WHERE folder = ' . $db->Quote($row->folder) . ' AND published > 0' . ' AND ' . $where . ' AND ordering > -10000' . ' AND ordering < 10000' . ' ORDER BY ordering';
             $order = JHTML::_('list.genericordering', $query);
             $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering));
         } else {
             $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . JText::_('This plugin cannot be reordered');
         }
         $lang =& JFactory::getLanguage();
         $lang->load('plg_' . trim($row->folder) . '_' . trim($row->element), JPATH_ADMINISTRATOR);
         $data = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . 'plugins' . DS . $row->folder . DS . $row->element . '.xml');
         $row->description = $data['description'];
     } else {
         $row->folder = '';
         $row->ordering = 999;
         $row->published = 1;
         $row->description = '';
     }
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
     $params = KService::get('com://admin/base.template.helper.form')->getParameters(array('path' => JApplicationHelper::getPath('plg_xml', $row->folder . DS . $row->element), 'data' => $row->params));
     //$params = new JParameter( $row->params, , 'plugin' );
     $this->assignRef('lists', $lists);
     $this->assignRef('plugin', $row);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Пример #20
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     $timeThen = microtime(true);
     //some legacy cleanup
     $legacyTables = array('categories', 'content', 'content_frontpage', 'core_log_items', 'migration_backlinks', 'migrations', 'sections', 'stats_agents', 'tagmeta', 'core_log_searches');
     foreach ($legacyTables as $legacyTable) {
         dbexec('DROP TABLE IF EXISTS #__' . $legacyTable);
     }
     //delete a legacy record
     dbexec('DELETE FROM #__components WHERE `option` = \'com_mailto\' ');
     //add the hashtag contentfilter
     dbexec('INSERT INTO #__plugins (name,element,folder,iscore) VALUES (\'Hashtag\', \'hashtag\',\'contentfilter\',1)');
     //create the fields required for creating hashtag nodes
     dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_count`');
     dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_ids`');
     //install the hashtag related extensions
     dbexec('INSERT INTO #__components (`name`,`link`,`option`,`iscore`,`enabled`) VALUES (\'Hashtags\',\'option=com_hashtags\',\'com_hashtags\',1,1)');
     $ids = array();
     //fetch only the nodes that contain something that resembels a hashtag
     $query_regexp = 'body REGEXP \'#([^0-9_\\s\\W].{2,})\'';
     dboutput("\nActors' Hashtags\n");
     //extracting hashtag terms from actors
     $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComActorsDomainEntityActor%\' AND ' . $query_regexp);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/actors.domain.entity.actor')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->description);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dboutput("\nComments' hashtags\n");
     //extracting hashtag terms from comments
     $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComBaseDomainEntityComment%\' AND ' . $query_regexp);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/base.domain.entity.comment')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->body);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dboutput("\nMedia's Hashtags\n");
     //extracting hashtag terms from mediums: notes, topics, pages, and todos
     $query = 'SELECT id FROM #__anahita_nodes WHERE ' . $query_regexp . ' AND ( ' . 'type LIKE \'%com:notes.domain.entity.note\' ' . 'OR type LIKE \'%com:topics.domain.entity.topic\' ' . 'OR type LIKE \'%com:photos.domain.entity.photo\' ' . 'OR type LIKE \'%com:photos.domain.entity.set\' ' . 'OR type LIKE \'%com:pages.domain.entity.page\' ' . 'OR type LIKE \'%com:todos.domain.entity.todo\' ' . ' ) ';
     $ids = dbfetch($query);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/medium.domain.entity.medium')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->description);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dbexec('UPDATE #__plugins SET published = 1 WHERE element = \'hashtag\'');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Пример #21
0
 /**
  * Gets the service identifier.
  *
  * @return	KServiceIdentifier
  * @see 	KObjectServiceable
  */
 public final function getIdentifier($identifier = null)
 {
     if (isset($identifier)) {
         $result = $this->__service_container->getIdentifier($identifier);
     } else {
         $result = $this->__service_identifier;
     }
     return $result;
 }
Пример #22
0
 /**
  * @{inheritdoc}
  */
 public function toSerializableArray($entity)
 {
     $data = parent::toSerializableArray($entity);
     $data['username'] = $entity->username;
     if (KService::has('com:people.viewer') && KService::get('com:people.viewer')->eql($entity)) {
         $data['email'] = $entity->email;
     }
     return $data;
 }
Пример #23
0
 /**
  * Injects behaviors to target identifiers.
  *
  * @param array $dependencies Associative array with target identifiers as keys and arrays
  *                            with behavior identifiers as values.
  *
  * @see ComLogmanPluginInjector::inject()
  */
 public final function inject($dependencies = array())
 {
     foreach ($dependencies as $target => $behaviors) {
         $behaviors = (array) $behaviors;
         foreach ($behaviors as $behavior) {
             KService::setConfig($target, array('behaviors' => array($behavior)));
         }
     }
 }
Пример #24
0
 /**
  * Constructor.
  *
  * @param mixed $dispatcher A dispatcher
  * @param array $config     An optional KConfig object with configuration options.
  *
  * @return void
  */
 public function __construct($dispatcher = null, $config = array())
 {
     if (isset($config['params'])) {
         $config = (array) JRegistryFormat::getInstance('ini')->stringToObject($config['params']);
     }
     $config = new KConfig($config);
     parent::__construct($config);
     $this->_params = $config;
     KService::set('plg:storage.default', $this);
 }
 public function postflight($type, $installer)
 {
     global $installer_manifest, $installer_source;
     // Need to do this as Joomla 2.5 "protects" parent and manifest properties of the installer
     $source = $installer_source;
     $manifest = $installer_manifest;
     $extension_id = ComExtmanInstaller::getExtensionId(array('type' => 'component', 'element' => 'com_' . $this->component));
     $extension = KService::get('com://admin/extman.controller.extension')->add(array('source' => $source, 'manifest' => $manifest, 'joomla_extension_id' => $extension_id, 'event' => $type === 'update' ? 'update' : 'install'));
     echo KService::get('com://admin/extman.controller.extension')->id($extension->id)->event($type === 'update' ? 'update' : 'install')->layout('success')->display();
 }
Пример #26
0
 /**
  * Return the singleton instnace of PlgContentfilterChain. This method also imports all the
  * content filter plugins.
  *
  * @return PlgContentfilterChain
  */
 public static function getInstance()
 {
     static $_instance;
     if (!$_instance) {
         $_instance = new self(new KConfig(array('service_container' => KService::getInstance())));
         KService::set('plg:contentfilter.chain', $_instance);
         JPluginHelper::importPlugin('contentfilter');
     }
     return $_instance;
 }
Пример #27
0
 /**
  * Initializes the default configuration for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     //@todo not crazy about this approach, but there was no way
     //that I could obtain the locatable from the controller
     $locatable_id = KRequest::get('get.locatable_id', 'int', 0);
     if (!$this->_locatable && $locatable_id) {
         $this->_locatable = KService::get('repos:nodes.node')->getQuery()->id($locatable_id)->fetch();
     }
     parent::_initialize($config);
 }
Пример #28
0
 public function setAliases()
 {
     if (!$this->_loaded) {
         $maps = array('com://site/wufoo.model.forms' => 'com://admin/wufoo.model.forms', 'com://site/wufoo.model.entries' => 'com://admin/wufoo.model.entries');
         foreach ($maps as $alias => $identifier) {
             KService::setAlias($alias, $identifier);
         }
         $this->setLoaded(true);
     }
     return $this;
 }
Пример #29
0
 /**
  *  Method to fetch the locatable object
  *
  *
  */
 public function fetchLocatable(KCommandContext $context)
 {
     $this->locatable = KService::get('repos:nodes.node')->getQuery()->disableChain()->id($this->locatable_id)->fetch();
     if (!$this->locatable) {
         throw new LibBaseControllerExceptionNotFound('Locatable object does not exist');
     }
     if (!$this->locatable->getRepository()->hasBehavior('geolocatable')) {
         throw new LibBaseControllerExceptionBadRequest('Object does not have locatable behavior');
     }
     return $this->locatable;
 }
Пример #30
0
 public function setAliases()
 {
     if (!$this->_loaded) {
         $maps = array();
         foreach ($maps as $alias => $identifier) {
             KService::setAlias($alias, $identifier);
         }
         $this->setLoaded(true);
     }
     return $this;
 }