示例#1
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);
         }
     }
 }
示例#2
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&view=articles&layout=modal&tmpl=component&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);
    }
示例#3
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;
 }
示例#4
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
         }
     }
 }
示例#5
0
 /**
  * Get an instance of a class based on a class identifier only creating it
  * if it doesn't exist yet.
  *
  * @param	string|object	The class identifier or identifier object
  * @param	array  			An optional associative array of configuration settings.
  * @throws	KObjectException if the service container has not been defined.
  * @return	object  		Return object on success, throws exception on failure
  * @see 	KObjectServiceable
  */
 public final function getService($identifier, array $config = array())
 {
     if (!isset($this->__service_container)) {
         throw new KObjectException("Failed to call " . get_class($this) . "::getService(). No service_container object defined.");
     }
     return $this->__service_container->get($identifier, $config);
 }
 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;
 }
示例#7
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);
 }
示例#8
0
文件: 2.php 项目: stonyyi/anahita
 /**
  * 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");
 }
示例#9
0
文件: 2.php 项目: walteraries/anahita
 /**
  * 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");
 }
 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));
 }
示例#11
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();
                 }
             }
         }
     }
 }
示例#12
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;
}
示例#13
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;
}
示例#14
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;
     }
 }
示例#15
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.'));
 }
示例#16
0
文件: koowa.php 项目: Roma48/mayak
 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);
 }
示例#17
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);
 }
示例#18
0
文件: 5.php 项目: walteraries/anahita
 /**
  * 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");
 }
示例#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
 /**
  * @{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;
 }
 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();
 }
示例#22
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);
 }
示例#23
0
 public function build(&$query)
 {
     $segments = array();
     if ($query['id'] && !$query['slug']) {
         if ($query['view'] == 'portal') {
             $portal = KService::get('com://site/portals.model.portals')->id($query['id'])->getItem();
             $segments['slug'] = $portal->slug;
         }
     }
     return $segments;
 }
示例#24
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;
 }
示例#25
0
 public function __get($name)
 {
     if ($name == 'container' && isset($this->_data[$name]) && is_string($this->_data[$name]->value)) {
         $this->_data[$name]->value = KService::get('com://admin/files.model.containers')->slug($this->_data[$name]->value)->getItem();
     } else {
         if ($name == 'basepath') {
             return (string) (isset($this->_data['container']) ? $this->container : '');
         }
     }
     return parent::__get($name);
 }
示例#26
0
 public function __construct($subject, $config = array())
 {
     //Intercept the events for profiling
     if (KDEBUG) {
         //Create the event profiler
         $profiler = KService::get('com://admin/debug.profiler.events');
         //Replace the event dispatcher
         KService::set('koowa:event.dispatcher', $profiler);
     }
     parent::__construct($subject, $config);
 }
示例#27
0
文件: 9.php 项目: walteraries/anahita
 /**
  * Called when migrating up
  */
 public function up()
 {
     //looks like these two didn't work in previous migrations
     dbexec("DROP TABLE #__content_rating");
     dbexec("DELETE FROM #__components WHERE `option` IN  ('com_media', 'com_menus', 'com_modules')");
     //add github gist plugin
     dbexec("INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES (49, 'Content Filter - GithubGist', 'gist', 'contentfilter', 0, 0, 0, 0, 0, 0, '0000-00-00 00:00:00', '')");
     //remove the syntax plugin
     dbexec("DELETE FROM #__plugins WHERE `element` IN ('syntax', 'ptag') ");
     //UTF-8 conversions
     dbexec("ALTER DATABASE CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_edges CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMBLOB");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMTEXT CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__migrator_migrations CHARACTER SET utf8");
     dbexec("ALTER TABLE #__migrator_versions CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     //move these to related components
     dbexec("ALTER TABLE #__invites_tokens CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_coupons CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_packages CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_transactions CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_vats CHARACTER SET utf8");
     dbexec("ALTER TABLE #__todos_todos CHARACTER SET utf8");
     dbexec("ALTER TABLE #__topics_topics CHARACTER SET utf8");
     dbexec("ALTER TABLE #__users CHARACTER SET utf8");
     dbexec("ALTER TABLE #__users CHANGE name name VARBINARY(255)");
     dbexec("ALTER TABLE #__users CHANGE name name VARCHAR(255) CHARACTER SET utf8");
     //updating comments
     $timeThen = microtime(true);
     $db = KService::get('koowa:database.adapter.mysqli');
     //change comment formats from html to string
     $entities = dbfetch('SELECT id, body FROM #__anahita_nodes WHERE type LIKE "ComBaseDomainEntityComment%" ');
     dboutput("Updating comments. This WILL take a while ...\n");
     foreach ($entities as $entity) {
         $id = $entity['id'];
         $body = strip_tags($entity['body']);
         $db->update('anahita_nodes', array('body' => $body), ' WHERE id=' . $id);
     }
     dboutput("Comments updated!\n");
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
示例#28
0
 function fetchElement($name, $value, &$node = null, $control_name = null)
 {
     $el_name = $control_name ? $control_name . '[' . $name . ']' : $name;
     $tree = KService::get('com://admin/files.controller.folder')->container('fileman-files')->tree(1)->limit(0)->browse();
     $options = array();
     $options[] = array('text' => JText::_('Root Folder'), 'value' => '');
     foreach ($tree as $folder) {
         $this->_addFolder($folder, $options);
     }
     return KService::get('com://admin/fileman.template.helper.select')->optionlist(array('name' => $el_name, 'options' => $options, 'showroot' => false, 'selected' => $value));
 }
示例#29
0
 protected function getInput()
 {
     // I will have to generate a list.
     // But it has to consist of all the items which we will need.
     // Although this isn't really defined up front and changable per project.
     $articles = KService::get('com://admin/articles.model.articles')->getList()->getData();
     $events = KService::get('com://admin/events.model.events')->getList()->getData();
     $data = array();
     $data[] = array('text' => 'articles', 'items' => array_map(array($this, '_parseItems'), $articles));
     $data[] = array('text' => 'events', 'items' => array_map(array($this, '_parseItems'), $events));
     return JHtml::_('select.groupedlist', $data, $this->name);
 }
示例#30
0
 public function get($name, $default = null)
 {
     $result = parent::get($name, $default);
     if ($name === 'container' && is_string($result)) {
         $result = KService::get('com://admin/files.model.containers')->slug($result)->getItem();
         if (!is_object($result) || $result->isNew()) {
             throw new KModelException('Invalid container');
         }
         $this->_data['container']->value = $result;
     }
     return $result;
 }