本文整理汇总了PHP中KFactory::tmp方法的典型用法代码示例。如果您正苦于以下问题:PHP KFactory::tmp方法的具体用法?PHP KFactory::tmp怎么用?PHP KFactory::tmp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFactory
的用法示例。
在下文中一共展示了KFactory::tmp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importXml
public function importXml(SimpleXMLElement $xml)
{
parent::importXml($xml);
foreach ($this->_xml->option as $option) {
$elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml($option);
$this->addOption($elem);
}
if ($this->_xml['get']) {
$get = isset($this->_xml['tmp']) && $this->_xml['tmp'] == true ? KFactory::tmp(new KIdentifier($this->_xml['get'])) : KFactory::get(new KIdentifier($this->_xml['get']));
if ($this->_xml['set']) {
$json = '{"' . str_replace(array(';', ':'), array('","', '":"'), (string) $this->_xml['set']) . '"}';
$states = json_decode(str_replace('",""}', '"}', $json));
foreach ($states as $state => $set) {
$get->{$state}($set);
}
}
$key = $this->_xml['key'] ? $this->_xml['key'] : 'title';
$val = $this->_xml['val'] ? $this->_xml['val'] : 'id';
foreach ($get->getList() as $item) {
$string = '<option value="' . $item->{$val} . '">' . $item->{$key} . '</option>';
$elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml(simplexml_load_string($string));
$this->addOption($elem);
}
}
return $this;
}
示例2: __construct
public function __construct(KConfig $config)
{
$sluggable = KFactory::tmp('lib.koowa.database.behavior.sluggable', array('columns' => array('name')));
$config->table_behaviors = array($sluggable, 'orderable', 'lockable', 'creatable', 'modifiable');
parent::__construct($config);
$this->_state->insert('jedi_rank_id', 'int')->insert('enabled', 'int');
}
示例3: display
public function display()
{
// Display the toolbar
$toolbar = $this->_createToolbar()->reset();
$this->toolbar = KFactory::get($this->getToolbar(), array('isGrid' => false))->append(KFactory::get('admin::com.ninja.toolbar.button.apply', array('isGrid' => false)));
KFactory::get('admin::com.ninja.helper.default')->css('/' . $this->getIdentifier()->application . '.' . $this->getName() . '.css');
KFactory::get('admin::com.ninja.helper.default')->js('/raphael.js');
KFactory::get('admin::com.ninja.helper.default')->js('/Mapper.js');
$acl = JFactory::getACL();
//die('<pre>'.print_r(get_class_methods($acl), true).'</pre>');
$acltree = (array) $acl->get_group_children_tree(null, 'USERS', false);
array_unshift($acltree, (object) array('value' => 0, 'text' => 'Unregistered', 'disabled' => false));
$this->acltree = $acltree;
$this->usergroups = KFactory::tmp('admin::com.ninjaboard.model.usergroups')->limit(0)->getList();
$maps = array();
foreach (KFactory::tmp($this->getModel()->getIdentifier())->limit(0)->getList() as $map) {
$maps[$map->id] = $map->ninjaboard_gid;
}
$this->maps = $maps;
$display = parent::display();
if (KRequest::type() == 'AJAX') {
echo '<script type="text/javascript">
' . $this->_document->_script['text/javascript'] . '
</script>';
}
return $display;
}
示例4: setPermissions
/**
* Generic function for setting the permissions
*
* @return void
*/
public function setPermissions($context)
{
//Temp fix
if (KInflector::isPlural(KRequest::get('get.view', 'cmd')) || KRequest::type() == 'AJAX') {
return;
}
$model = KFactory::get($this->getModel());
$table = KFactory::tmp(KFactory::get(KFactory::get('admin::com.ninja.helper.access')->models->assets)->getTable());
$query = $table->getDatabase()->getQuery();
$item = $model->getItem();
$identifier = $this->getIdentifier();
$id = $identifier->type . '_' . $identifier->package . '.' . $identifier->name . '.' . $item->id . '.';
$permissions = (array) KRequest::get('post.permissions', 'int');
$editable = KRequest::get('post.editpermissions', 'boolean', false);
if (!$permissions && $editable) {
$query->where('tbl.name', 'LIKE', $id . '%');
$table->select($query)->delete();
}
$safe = array();
$query = $table->getDatabase()->getQuery()->where('name', 'like', $id . '%');
foreach ((array) KRequest::get('post.params.permissions', 'raw') as $group => $other) {
$safe[] = $id . $group;
}
if ($safe) {
$query->where('name', 'not in', $safe);
}
$table->select($query, KDatabase::FETCH_ROWSET)->delete();
foreach ($permissions as $usergroup => $rules) {
foreach ($rules as $name => $permission) {
KFactory::tmp(KFactory::get('admin::com.ninja.helper.access')->models->assets)->name($id . $usergroup . '.' . $name)->getItem()->setData(array('name' => $id . $usergroup . '.' . $name, 'level' => $permission))->save();
}
}
}
示例5: display
public function display($tpl = null)
{
$nooku = KFactory::get('admin::com.nooku.model.nooku');
$model = KFactory::get('admin::com.nooku.model.translators');
// Get data from model
$stats = $model->getStats();
$dates = $model->getDates();
// Get translators
$translators = $nooku->getTranslators();
// Get the languages
//$primary = $nooku->getPrimaryLanguage();
$languages = $nooku->getLanguages();
//unset($languages[$primary->iso_code]); // we don't display the primary lang in our chart
// Request
$table_name = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename'));
$user_id = KInput::get('user_id', 'get', 'int');
if (!$user_id) {
throw new KViewException('user_id is required in ' . JURI::getInstance()->toString());
}
// Utilities
$color = new NookuConfigColor();
// get the chart
$c = $this->getChart('line');
// Data
$i = 1;
foreach ($stats[$user_id]->count as $value) {
$c->setData($i++, $value);
}
// Layout
$c->SetLineSize(5);
// The Sparkline lib always draws in black, this hack lets us use other colors
$c->setColor('black', $color->get('blue'));
parent::display();
}
示例6: __get
/**
* Retrieve row field value
*
* @param string The column name.
* @return string The corresponding column value.
*/
public function __get($column)
{
if (strpos($column, '_permissions') === false) {
return parent::__get($column);
}
$object = str_replace('_permissions', '', $column);
if (!isset($this->_permissions[$object])) {
$table = KFactory::get('admin::com.ninjaboard.database.table.assets');
$query = KFactory::tmp('lib.koowa.database.query');
$me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
$gids = explode('|', $me->ninjaboard_usergroup_id);
//If super admin, then the permission level is always 3
if ($me->gid == 25) {
return $this->_permissions[$object] = 3;
}
$query->select('IFNULL(tbl.level, ' . (int) $me->{$object . '_permissions'} . ') AS level')->from('ninjaboard_assets AS tbl')->order('tbl.level', 'DESC')->limit(1);
$where = array();
foreach ($gids as $gid) {
$where[] = 'com_ninjaboard.forum.' . (int) $this->id . '.' . $gid . '.' . $object;
}
if ($where) {
$query->where('tbl.name', 'in', $where);
}
$result = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD);
$this->_permissions[$object] = is_numeric($result) ? $result : $me->{$object . '_permissions'};
}
return $this->_permissions[$object];
}
示例7: _actionEdit
public function _actionEdit(KCommandContext $context)
{
$data = $context->data;
$model = $this->getModel();
$table = $model->getTable();
$query = KFactory::tmp('lib.koowa.database.query');
$ids = array();
foreach ($data['group'] as $joomla => $ninjaboard) {
$ids[] = $joomla;
}
$table->getDatabase()->execute('TRUNCATE TABLE `#__ninjaboard_joomla_user_group_maps`');
foreach ($ids as $id) {
$table->getDatabase()->execute('INSERT INTO `#__ninjaboard_joomla_user_group_maps` (`joomla_gid`, `ninjaboard_gid`) VALUES (' . $id . ', ' . (int) $data['group'][$id] . ')');
//$table->insert(array('joomla_gid' => $id, 'ninjaboard_gid' => $data['group'][$id]));
}
$tmpl = false;
if (KRequest::get('post.tmpl', 'cmd') == 'component') {
$tmpl = '&tmpl=component';
}
$this->_redirect = 'index.php?option=com_ninjaboard&view=joomlausergroupmaps' . $tmpl;
if ($tmpl) {
$this->_redirect_message = '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>';
}
// @TODO this is a temporary workaround, find out why the proper way, using setRedirect(), stopped working.
echo $this->_redirect_message;
//$this->setRedirect('view=joomlausergroupmaps'.$tmpl, $tmpl ? '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>' : null);
return $this->getModel()->getList();
}
示例8: display
public function display()
{
$targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
$thing = reset($targets);
$string = substr($thing['title'], 3);
$option = strtolower(substr($string, 0, stripos($string, 'controller')));
$view = strtolower(substr($string, stripos($string, 'controller') + 10));
$model = KInflector::pluralize($view);
$list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData();
$array = array();
foreach ($list as $item) {
$array[] = $item['id'];
}
//Get the list of posts
$activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList();
$myactivities = array();
foreach (@$activities as $activity) {
if (!in_array($activity->parent_target_id, $array)) {
continue;
} else {
$myactivities[] = $activity;
}
}
$this->assign('myactivities', $myactivities);
$this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination);
return parent::display();
}
示例9: render
public function render()
{
$id = 'toolbar-' . $this->getName();
$html = array();
// Start toolbar div
if (JVERSION::isCompatible('1.6')) {
$html[] = '<div class="toolbar-list" id="' . $id . '">';
} else {
$html[] = '<div class="toolbar" id="' . $id . '">';
}
$html[] = '<table class="toolbar"><tr>';
// Render each button in the toolbar
foreach ($this->_buttons as $button) {
if (!$button instanceof KToolbarButtonInterface) {
$app = $this->_identifier->application;
$package = $this->_identifier->package;
$button = KFactory::tmp($app . '::com.' . $package . '.toolbar.button.' . $button);
}
$button->setParent($this);
$html[] = $button->render();
}
// End toolbar div
$html[] = '</tr></table>';
$html[] = '</div>';
return implode(PHP_EOL, $html);
}
示例10: display
public function display($tpl = null)
{
$menu = JSite::getMenu();
$params = $menu->getParams($menu->getActive()->id);
$url = KFactory::tmp('lib.koowa.filter.url')->sanitize($params->get('url'));
KFactory::get('lib.joomla.application')->redirect($url);
}
示例11: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
$buffer = '';
$chain = $node->children();
if (!defined('NINJA_CHAIN')) {
$document = KFactory::get('lib.joomla.document');
$document->addStyleDeclaration("\n\t\t\t\t.wrapper {\n\t\t\t\t\t-webkit-border-radius: 3px;\n\t\t\t\t\t-moz-border-radius: 3px;\n\t\t\t\t\tborder-radius: 3px;\n\t\t\t\t\tbackground-color: #EBEBEB;\n\t\t\t\t\tbackground-color: hsla(0, 0%, 94%, 0.8);\n\t\t\t\t\tborder: 1px solid #E6E6E6;\n\t\t\t\t\tborder-color: hsla(0, 0%, 90%, 0.8);\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t\tpadding: 6px;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t.wrapper .chain-label {\n\t\t\t\t\tdisplay: block;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.wrapper .chain .value, .wrapper .chain ul.group {\n\t\t\t\t\tmargin-left: auto!important;\n\t\t\t\t}\n\t\t\t");
define('NINJA_CHAIN', 1);
}
//
$buffer .= "<div class='wrapper'>";
foreach ($chain as $item) {
//get the type of the parameter
$type = (string) $item['type'];
try {
$identifier = new KIdentifier($type);
} catch (KException $e) {
$identifier = 'admin::com.ninja.element.' . $type;
}
$chaindata = $this->_parent->get((string) $node['name']);
if (isset($chaindata[(string) $item['name']]) && $chaindata[(string) $item['name']] !== false) {
$value = $chaindata[(string) $item['name']];
} else {
$value = (string) $item['default'];
}
$element = KFactory::tmp($identifier, array('parent' => $this->_parent, 'node' => $item, 'value' => $value, 'field' => $this->field, 'group' => $this->_parent->getGroup(), 'name' => $name . '[' . (string) $item['name'] . ']', 'fetchTooltip' => false));
$buffer .= '<div class="chain ' . $name . '_' . (string) $item['name'] . ' chain-' . $type . '">';
$buffer .= '<span class="chain-label">' . JText::_($element->label) . '</span>';
$buffer .= $element->toString();
$buffer .= "</div>";
}
$buffer .= "</div>";
return $buffer;
}
示例12: render
public function render()
{
$name = $this->getName();
$img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png');
if ($img) {
KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }');
}
$text = JText::_($this->_options['text']);
$view = KRequest::get('get.view', 'cmd');
$link = ' href="' . JRoute::_($this->getLink()) . '"';
$html = array();
// Sanitize the url since we can't trust the server var
$url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink());
// Create the URI object
$uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url));
$query = $uri->getQuery(1);
$html[] = '<td class="button" id="' . $this->getId() . '">';
$active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view']));
$hide = !KInflector::isPlural($view);
if ($active || $hide || !$this->modal) {
$html[] = '<a class="toolbar inactive">';
} else {
$html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">';
}
$html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">';
$html[] = '</span>';
$html[] = $text;
if (!$active && !$hide || $this->modal) {
$html[] = '</a>';
} else {
$html[] = '</a>';
}
$html[] = '</td>';
return implode(PHP_EOL, $html);
}
示例13: image
/**
* Renders the html markup for the user avatar
*
* @author Stian Didriksen <stian@ninjaforge.com>
* @return string
*/
public function image($config = array())
{
$params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams();
$prepend = KFactory::get('lib.joomla.application')->isAdmin() ? KRequest::root() . '/' : '';
$config = new KConfig($config);
$config->append(array('id' => KFactory::get('admin::com.ninjaboard.model.people')->getMe()->id, 'thumbnail' => 'large', 'class' => 'avatar', 'link' => 'person', 'type' => 'css'));
$person = KFactory::tmp('admin::com.ninjaboard.model.people')->id($config->id)->getItem();
$avatar_on = new DateTime($person->avatar_on);
$cache = (int) $avatar_on->format('U');
$config->append(array('avatarurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=avatar&id=' . $config->id . '&thumbnail=' . $config->thumbnail . '&cache=' . $cache), 'profileurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=person&id=' . $config->id)));
$attribs = array('class' => $config->class, 'href' => $config->profileurl);
$height = $params['avatar_settings'][$config->thumbnail . '_thumbnail_height'];
$width = $params['avatar_settings'][$config->thumbnail . '_thumbnail_width'];
///* @TODO Following is the <img /> version, likely going to be deprecated
if ($config->type == 'tag') {
$attribs['src'] = $config->avatarurl;
$attribs['height'] = $height;
$attribs['width'] = $width;
unset($attribs['href']);
$html = '<img ' . KHelperArray::toString($attribs) . ' />';
} else {
$style = 'background-image: url(' . $config->avatarurl . '); ';
$style .= 'height: ' . $height . 'px; ';
$style .= 'width: ' . $width . 'px;';
$attribs['style'] = $style;
$html = '<a ' . KHelperArray::toString($attribs) . '></a>';
}
return $html;
}
示例14: display
public function display($tpl = null)
{
// Request
$month = KInput::get('month', 'get', 'digit', null, date('m'));
$year = KInput::get('year', 'get', 'int', null, date('Y'));
$graph = KInput::get('graph', 'get', 'cmd', null, 'translations');
$table_name = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename'), null, '');
$this->assign('graph', $graph);
$this->assign('table_name', $table_name);
$this->assign('month', $month);
$this->assign('year', $year);
// URI
$uri =& JURI::getInstance(JURI::base() . 'index.php?option=com_nooku&format=openflashchart');
$uri->setVar('table_name', $table_name);
$uri->setVar('layout', 'bar');
$uri->setVar('view', 'statistics.translations');
$this->assign('translations', $uri->toString());
$uri->setVar('year', date('Y'));
$uri->setVar('month', date('n'));
$uri->setVar('view', 'statistics.translators');
$this->assign('translators', $uri->toString());
// panes
Koowa::import('lib.joomla.html.pane');
$this->assignRef('panes', JPane::getInstance('tabs'));
// Mixin a menubar object
$this->mixin(new NookuMixinMenu($this));
$this->displayMenubar();
$this->displayMenutitle();
$this->displayToolbar();
// Display the layout
parent::display($tpl);
}
示例15: display
public function display()
{
$topic = $this->getModel()->getItem();
$this->forum = KFactory::get('site::com.ninjaboard.model.forums')->id($topic->forum_id)->getItem();
$this->user = KFactory::get('lib.joomla.user');
$me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
$this->watch_button = $me->id && $this->forum->params['email_notification_settings']['enable_email_notification'];
//Assign forum permissions to topic
$topic->forum_permissions = $this->forum->forum_permissions;
$topic->topic_permissions = $this->forum->topic_permissions;
$topic->post_permissions = $this->forum->post_permissions;
$topic->attachment_permissions = $this->forum->attachment_permissions;
if ((!$this->forum->id || !$topic->id || $topic->topic_permissions < 1) && KFactory::tmp('lib.joomla.user')->guest) {
$this->mixin(KFactory::get('admin::com.ninja.view.user.mixin'));
$this->setLoginLayout();
return parent::display();
} elseif (!$topic->id) {
JError::raiseError(404, JText::_("Topic not found."));
return;
} elseif (!$this->forum->id) {
JError::raiseError(404, JText::_("Forum not found."));
return;
}
$this->_subtitle = $topic->title;
//if($topic->id && !KRequest::get('get.layout', 'cmd', false)) $this->setLayout('default');
$state = $this->getModel()->getState();
$limit = $state->limit ? $state->limit : 6;
$offset = KFactory::tmp('site::com.ninjaboard.model.posts')->topic($topic->id)->post($state->post)->limit($limit)->getOffset();
$offset = KRequest::get('get.offset', 'int', $offset);
//This is used to set the canonical link correctly in the topic controller after.read
//@TODO move all this logic out of the view in 1.2
$this->getModel()->set(array('limit' => $limit, 'offset' => $offset));
$this->assign('posts', KFactory::tmp('site::com.ninjaboard.controller.post')->setView(KFactory::tmp('site::com.ninjaboard.view.posts.html'))->setModel(KFactory::get('site::com.ninjaboard.model.posts')->setAcl(false))->sort('created_on')->limit($limit)->offset($offset)->post(false)->topic($topic->id)->layout('default')->display());
if ($this->forum->params['view_settings']['new_topic_button'] == 'topic') {
$this->new_topic_button = '<div class="new-topic">' . str_replace(array('$title', '$link'), array(JText::_('New Topic'), $this->createRoute('view=post&forum=' . $this->forum->id)), $this->forum->params['tmpl']['new_topic_button']) . '</div>';
}
$button = false;
if (KFactory::get('lib.joomla.user')->guest || $this->forum->post_permissions > 1) {
$button = str_replace(array('$title', '$link'), array(JText::_('Reply topic'), $this->createRoute('view=post&topic=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']);
}
//$this->reply_topic_button = $this->forum->post_permissions > 1 ? $button : null;
$this->reply_topic_button = $button;
$this->lock_topic_button = null;
$this->move_topic_button = null;
$this->delete_topic_button = null;
if ($this->forum->topic_permissions > 2) {
$this->lock_topic_button = $this->_createActionButton('lock', 'Lock topic', $topic->id, 'lock');
$this->move_topic_button = str_replace(array('$title', '$link'), array(JText::_('Move topic'), $this->createRoute('view=topic&layout=move&id=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']);
$this->delete_topic_button = $this->_createActionButton('delete', 'Delete topic', $topic->id, 'trash');
}
$output = parent::display();
//@TODO move this to the controller
$hit = KRequest::get('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), 'boolean');
if (!$hit && $topic->created_user_id != $me->id) {
$topic->hit();
KRequest::set('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), true);
}
return $output;
}