本文整理汇总了PHP中KService类的典型用法代码示例。如果您正苦于以下问题:PHP KService类的具体用法?PHP KService怎么用?PHP KService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setConfig
/**
* 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: _beforeDispatch
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: onContentSearch
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: __construct
/**
* 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: updateIndex
/**
* @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: onAuthenticate
/**
* 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: __construct
/**
* 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: filter
/**
* 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: up
/**
* 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: plgSearchEvents
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: getInput
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 . '&' . 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: up
/**
* 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: fetchElement
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: fetchElement
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: _actionCopy
/**
* @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);
}
}
}