本文整理汇总了PHP中JModelLegacy类的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy类的具体用法?PHP JModelLegacy怎么用?PHP JModelLegacy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JModelLegacy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete($pk = null)
{
// Get form model
$formModel = JModelLegacy::getInstance('form', 'IssnregistryModel');
if ($pk != null) {
// Get number of forms related to this publisher
$formsCount = $formModel->getFormsCountByPublisherId($pk);
// Check result
if ($formsCount != 0) {
// If there are forms, the publisher can't be deleted
JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_PUBLISHER_DELETE_FAILED_FORMS_EXIST'), 'warning');
// Return false as the item can't be deleted
return false;
}
// Delete messages
//$messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
//$messageModel->deleteByPublisherId($pk);
}
if (parent::delete($pk)) {
// If this publisher was created based on a form, remove
// publisher created attribute from the form
if ($this->form_id != 0) {
$formModel->removePublisherCreated($this->form_id);
}
// Get message model
$messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
// Delete messages related to this publisher
$messageModel->deleteByPublisherId($pk);
// Return true
return true;
}
return false;
}
示例2: passPHP
function passPHP(&$parent, &$params, $selection = array(), $assignment = 'all', $article = 0)
{
if (!is_array($selection)) {
$selection = array($selection);
}
$pass = 0;
foreach ($selection as $php) {
// replace \n with newline and other fix stuff
$php = str_replace('\\|', '|', $php);
$php = preg_replace('#(?<!\\\\)\\\\n#', "\n", $php);
$php = trim(str_replace('[:REGEX_ENTER:]', '\\n', $php));
if ($php == '') {
$pass = 1;
break;
}
if (!$article && strpos($php, '$article') !== false) {
$article = '';
if ($parent->params->option == 'com_content' && $parent->params->view == 'article') {
require_once JPATH_SITE . '/components/com_content/models/article.php';
$model = JModelLegacy::getInstance('article', 'contentModel');
$article = $model->getItem($parent->params->id);
}
}
if (!isset($Itemid)) {
$Itemid = JFactory::getApplication()->input->getInt('Itemid', 0);
}
if (!isset($mainframe)) {
$mainframe = JFactory::getApplication();
}
if (!isset($app)) {
$app = JFactory::getApplication();
}
if (!isset($document)) {
$document = JFactory::getDocument();
}
if (!isset($doc)) {
$doc = JFactory::getDocument();
}
if (!isset($database)) {
$database = JFactory::getDBO();
}
if (!isset($db)) {
$db = JFactory::getDBO();
}
if (!isset($user)) {
$user = JFactory::getUser();
}
$php .= ';return true;';
$temp_PHP_func = create_function('&$article, &$Itemid, &$mainframe, &$app, &$document, &$doc, &$database, &$db, &$user', $php);
// evaluate the script
ob_start();
$pass = (bool) $temp_PHP_func($article, $Itemid, $mainframe, $app, $document, $doc, $database, $db, $user);
unset($temp_PHP_func);
ob_end_clean();
if ($pass) {
break;
}
}
return $parent->pass($pass, $assignment);
}
示例3: display
/**
* Display
*
* @param string $tmpl Template
*
* @return void
*/
public function display($tmpl = 'default')
{
$srcs = FabrikHelperHTML::framework();
$app = JFactory::getApplication();
$input = $app->input;
FabrikHelperHTML::script($srcs);
$model = $this->getModel();
$usersConfig = JComponentHelper::getParams('com_fabrik');
$model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0))));
$visualization = $model->getVisualization();
$pluginParams = $model->getPluginParams();
$pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikModel');
$plugin = $pluginManager->getPlugIn($visualization->plugin, 'visualization');
$plugin->_row = $visualization;
if ($visualization->published == 0) {
return JError::raiseWarning(500, FText::_('COM_FABRIK_SORRY_THIS_VISUALIZATION_IS_UNPUBLISHED'));
}
// Plugin is basically a model
$pluginTask = $input->get('plugintask', 'render', 'request');
// @FIXME cant set params directly like this, but I think plugin model setParams() is not right
$plugin->_params = $pluginParams;
$tmpl = $plugin->getParams()->get('calendar_layout', $tmpl);
$plugin->{$pluginTask}($this);
$this->plugin = $plugin;
$viewName = $this->getName();
$this->addTemplatePath($this->_basePath . '/plugins/' . $this->_name . '/' . $plugin->_name . '/tmpl/' . $tmpl);
$root = $app->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE;
$this->addTemplatePath($root . '/templates/' . $app->getTemplate() . '/html/com_fabrik/visualization/' . $plugin->_name . '/' . $tmpl);
$ab_css_file = JPATH_SITE . '/plugins/fabrik_visualization/' . $plugin->_name . '/tmpl/' . $tmpl . '/template.css';
if (JFile::exists($ab_css_file)) {
JHTML::stylesheet('template.css', 'plugins/fabrik_visualization/' . $plugin->_name . '/tmpl/' . $tmpl . '/', true);
}
echo parent::display();
}
示例4: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$sport_id = $item->get('id');
$this->saveconfigs($sport_id);
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=cfgsport&layout=edit&id=' . $sport_id, false));
}
示例5: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$map_id = $item->get('id');
$mapimage = $item->get('mapimage');
$this->prepare_fileupload($map_id, $mapimage);
//in case new HR file added
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=omap&layout=edit&id=' . $map_id, false));
}
示例6: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$media_id = $item->get('id');
$mediafile = JRequest::getVar('filename');
$model->storeimage($mediafile, $media_id);
$this->prepare_fileupload($media_id, $mediafile);
//in case new m fedia file added
//$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=media&layout=edit&id='.$media_id, false));
}
示例7: postSaveHook
public function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$sub_id = $item->get('id');
$sport_id = $item->get('sport_id');
$this->saveomap();
$split_id = $this->prepare_fileupload($sub_id, $sport_id);
//in case new HR file added
$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id . '&split_id=' . $split_id, false));
}
示例8: postSaveHook
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
$id = $item->get('id');
if ($id) {
if ($validData['saveresult'] == 1) {
//Create a new datatable if it doesn't allready exist
if (!$model->createDataTables($id)) {
$this->setMessage($model->getError());
}
}
}
}
示例9: display
/**
* Display the Message templates view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
function display($tpl = null)
{
// Get data from the model
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Add menu helper file
require_once JPATH_COMPONENT . '/helpers/menu.php';
// Add sidebar
MenuHelper::addSubmenu('messagetemplates');
// Load message type model
$model = JModelLegacy::getInstance('messagetype', 'IssnregistryModel');
// Load message types
$types = $model->getMessageTypesHash();
// Pass $types to the layout
$this->assignRef('types', $types);
// Set the toolbar
$this->addToolBar();
// Render the sidebar
$this->sidebar = JHtmlSidebar::render();
// Display the template
parent::display($tpl);
}
示例10: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
// Get a reverse lookup of the base link URL to Title
$model = JModelLegacy::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Load the javascript and css
JHtml::_('behavior.framework');
JHtml::_('behavior.modal');
$html[] = '<span class="input-append"><input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' /><a class="btn btn-primary" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})"><i class="icon-list icon-white"></i> ' . JText::_('JSELECT') . '</a></span>';
$html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
return implode("\n", $html);
}
示例11: display
function display($tpl = NULL)
{
/**
* @var JSite $app
*/
$app = JFactory::getApplication();
$this->params = $app->getParams();
/* Default Page fallback*/
$active = $app->getMenu()->getActive();
if (NULL == $active) {
$this->params->merge($app->getMenu()->getDefault()->params);
$active = $app->getMenu()->getDefault();
}
$this->currentItemid = $active->id;
$entriesPerPage = $this->params->get('max_events_per_page', 12);
$model = $this->getModel('events');
$eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel');
$recursive = $this->params->get('show_items_per_category_recursive', false);
$user = JFactory::getUser();
$usergroups = JUserHelper::getUserGroups($user->id);
$entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->params->get('catid', null), $recursive);
$this->pageNav = $model->getPagination();
$this->entries = $entries;
$this->eventModel = $eventModel;
$this->_prepareDocument();
parent::display($tpl);
}
示例12: display
/**
* Called via ajax to perform viz ajax task (defined by plugintask method)
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController A JController object to support chaining.
*/
public function display($cachable = false, $urlparams = false)
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$input = $app->input;
$id = $input->getInt('visualizationid');
$viz = FabTable::getInstance('Visualization', 'FabrikTable');
$viz->load($id);
$modelpaths = JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/models');
$model = $this->getModel($viz->plugin);
$model->setId($id);
$pluginTask = $input->get('plugintask', '', 'request');
if ($pluginTask !== '') {
echo $model->{$pluginTask}();
} else {
$task = $input->get('task');
$path = JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/controllers/' . $viz->plugin . '.php';
if (file_exists($path)) {
require_once $path;
} else {
throw new RuntimeException('Could not load visualization: ' . $viz->plugin);
}
$controllerName = 'FabrikControllerVisualization' . $viz->plugin;
$controller = new $controllerName();
$controller->addViewPath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/views');
$controller->addViewPath(COM_FABRIK_FRONTEND . '/views');
// Add the model path
$modelpaths = JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/fabrik_visualization/' . $viz->plugin . '/models');
$modelpaths = JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models');
$origId = $input->getInt('visualizationid');
$input->set('visualizationid', $id);
$controller->{$task}();
}
return $this;
}
示例13: delete
/**
* Deletes a message type.
*
* @param integer $pk Primary key of the message type to be deleted.
*
* @return boolean True on success, false on failure.
*
*/
public function delete($pk = null)
{
// Add configuration helper file
require_once JPATH_COMPONENT . '/helpers/configuration.php';
// If message type is defined as default in configuration, it cannot be removed
if (ConfigurationHelper::isMessageTypeUsedInConfiguration($this->id)) {
// Raise a warning
JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_SETTINGS'), 'warning');
// Return false as the item can't be deleted
return false;
}
// Load message template model
$messageTemplateModel = JModelLegacy::getInstance('messagetemplate', 'IssnregistryModel');
// Get number of templates that use this message type
$templateCount = $messageTemplateModel->getMessageTemplatesCountByMessageType($this->id);
// If template count is not zero, message type cannot be deleted
if ($templateCount != 0) {
// Raise a warning
JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_USED'), 'warning');
// Return false as the item can't be deleted
return false;
}
// No ISSNs have been used, delete the item
return parent::delete($pk);
}
示例14: display
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->authors = $this->get('Authors');
$model = JModelLegacy::getInstance('Categories', 'TZ_Portfolio_PlusModel');
$model->setState('filter.group', $this->state->get('filter.group'));
$this->assign('listGroup', $model->getGroups());
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Levels filter.
$options = array();
$options[] = JHtml::_('select.option', '1', JText::_('J1'));
$options[] = JHtml::_('select.option', '2', JText::_('J2'));
$options[] = JHtml::_('select.option', '3', JText::_('J3'));
$options[] = JHtml::_('select.option', '4', JText::_('J4'));
$options[] = JHtml::_('select.option', '5', JText::_('J5'));
$options[] = JHtml::_('select.option', '6', JText::_('J6'));
$options[] = JHtml::_('select.option', '7', JText::_('J7'));
$options[] = JHtml::_('select.option', '8', JText::_('J8'));
$options[] = JHtml::_('select.option', '9', JText::_('J9'));
$options[] = JHtml::_('select.option', '10', JText::_('J10'));
$this->assign('f_levels', $options);
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal') {
$this->addToolbar();
}
TZ_Portfolio_PlusHelper::addSubmenu('featured');
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
示例15: display
/**
* Return statistics CSV file
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
function display($tpl = null)
{
$this->item = $this->get('Item');
// Get parameters
$jinput = JFactory::getApplication()->input;
$type = $jinput->get('type', null, 'string');
$begin = $jinput->get('begin', null, 'string');
$end = $jinput->get('end', null, 'string');
// Convert date strings to JDate objects
$beginDate = new JDate($begin);
$endDate = new JDate($end . ' 23:59:59');
// Get statistic model
$statisticModel = JModelLegacy::getInstance('statistic', 'IssnregistryModel');
// Get statistics
$csv = $statisticModel->getStats($type, $beginDate, $endDate);
// Set document properties
$document = JFactory::getDocument();
$document->setMimeEncoding('text/csv; charset="UTF-8"');
JResponse::setHeader('Content-disposition', 'attachment; filename="statistics.csv"', true);
// Write to output
$out = fopen('php://output', 'w');
// Loop through CSV data and write each row to output
foreach ($csv as $row) {
// Columns are tab separated
fputcsv($out, $row, "\t");
}
// Close output
fclose($out);
}