当前位置: 首页>>代码示例>>PHP>>正文


PHP JoomleagueHelper::getExtensions方法代码示例

本文整理汇总了PHP中JoomleagueHelper::getExtensions方法的典型用法代码示例。如果您正苦于以下问题:PHP JoomleagueHelper::getExtensions方法的具体用法?PHP JoomleagueHelper::getExtensions怎么用?PHP JoomleagueHelper::getExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JoomleagueHelper的用法示例。


在下文中一共展示了JoomleagueHelper::getExtensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

 /**
  * Overrides method to try to load model from extension if it exists
  */
 public static function getInstance($type, $prefix = '', $config = array())
 {
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
         $modelClass = $prefix . ucfirst($modelType) . ucfirst($extension);
         $result = false;
         if (!class_exists($modelClass)) {
             jimport('joomla.filesystem.path');
             $path = JPath::find(parent::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type)));
             if (!$path) {
                 $path = JPath::find(parent::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type)));
             }
             if ($path) {
                 require_once $path;
                 if (class_exists($modelClass)) {
                     $result = new $modelClass($config);
                     return $result;
                 }
             }
         } else {
             $result = new $modelClass($config);
             return $result;
         }
     }
     // Still here ? Then the extension doesn't override this, use regular way
     return parent::getInstance($type, $prefix, $config);
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:31,代码来源:jlgmodel.php

示例2: createView

 /**
  * Overrides method to first lookup into potential extension for the view.
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $result = null;
         // Clean the view name
         $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
         $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
         $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
         // Build the view class name
         $viewClassExtension = $classPrefix . $viewName . ucfirst($extension);
         if (!class_exists($viewClassExtension)) {
             jimport('joomla.filesystem.path');
             $path = JPath::find($this->paths['view'], $this->createFileName('view', array('name' => $viewName, 'type' => $viewType)));
             if ($path) {
                 require_once $path;
                 if (class_exists($viewClassExtension)) {
                     $result = new $viewClassExtension($config);
                     return $result;
                 }
             }
         } else {
             $result = new $viewClassExtension($config);
             return $result;
         }
     }
     // Still here ? Then the extension doesn't override this, use regular view
     return parent::createView($name, $prefix, $type, $config);
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:32,代码来源:jlgcontroller.php

示例3: array

 /**
  * Overrides method to try to load model from extension if it exists
  */
 public static function &getInstance($type, $prefix = '', $config = array())
 {
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
         $modelClass = $prefix . ucfirst($modelType) . ucfirst($extension);
         $result = false;
         if (!class_exists($modelClass)) {
             jimport('joomla.filesystem.path');
             $path = JPath::find(JModel::addIncludePath(), JModel::_createFileName('model', array('name' => $modelType)));
             if ($path) {
                 require_once $path;
                 if (class_exists($modelClass)) {
                     $result = new $modelClass($config);
                     return $result;
                 }
             }
         } else {
             $result = new $modelClass($config);
             return $result;
         }
     }
     $instance = parent::getInstance($type, $prefix, $config);
     return $instance;
 }
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:28,代码来源:jlgmodel.php

示例4: getExtensions

 public function getExtensions()
 {
     if (!$this->extensions) {
         $this->extensions = JoomleagueHelper::getExtensions($this->input->getInt('p', 0));
     }
     return $this->extensions;
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:7,代码来源:extensioncontroller.php

示例5: display

 function display($tpl = null)
 {
     $option = JRequest::getCmd('option');
     $app = JFactory::getApplication();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $mainframe =& JFactory::getApplication();
     $model = $this->getModel();
     $lists = array();
     //get template data
     $template =& $this->get('data');
     $isNew = $template->id < 1;
     // fail if checked out not by 'me'
     if ($model->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('COM_JOOMLEAGUE_ADMIN_TEMPLATE_THETEMPLATE'), $template->name);
         $app->redirect('index.php?option=' . $option, $msg);
     }
     $projectws =& $this->get('Data', 'projectws');
     $templatepath = JPATH_COMPONENT_SITE . DS . 'settings';
     $xmlfile = $templatepath . DS . 'default' . DS . $template->template . '.xml';
     $mainframe->setUserState($option . 'template_help', $template->template);
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $extensiontpath = JPATH_COMPONENT_SITE . DS . 'extensions' . DS . $extension;
         if (is_dir($extensiontpath . DS . 'settings' . DS . 'default')) {
             if (file_exists($extensiontpath . DS . 'settings' . DS . 'default' . DS . $template->template . '.xml')) {
                 $xmlfile = $extensiontpath . DS . 'settings' . DS . 'default' . DS . $template->template . '.xml';
             }
         }
     }
     $jRegistry = new JRegistry();
     $jRegistry->loadString($template->params, 'ini');
     $form =& JForm::getInstance($template->template, $xmlfile, array('control' => 'params'));
     $form->bind($jRegistry);
     $form_value = $form->getValue('person_events');
     if ($form_value) {
         $form->setValue('person_events', null, explode(",", $form_value));
     }
     $master_id = $projectws->master_template ? $projectws->master_template : '-1';
     $templates = array();
     //$templates[]=JHTML::_('select.option','0',JText::_('COM_JOOMLEAGUE_ADMIN_TEMPLATE_OTHER_TEMPLATE' ),'value','text');
     if ($res = $model->getAllTemplatesList($projectws->id, $master_id)) {
         $templates = array_merge($templates, $res);
     }
     $lists['templates'] = JHTMLSelect::genericlist($templates, 'select_id', 'class="inputbox" size="1" onchange="javascript: Joomla.submitbutton(\'template.apply\');"', 'value', 'text', $template->id);
     unset($res);
     unset($templates);
     $this->assignRef('request_url', $uri->toString());
     $this->assignRef('template', $template);
     $this->assignRef('form', $form);
     $this->assignRef('project', $projectws);
     $this->assignRef('lists', $lists);
     $this->assignRef('user', $user);
     $this->addToolbar();
     parent::display($tpl);
 }
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:56,代码来源:view.html.php

示例6: display

 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $option = $jinput->getCmd('option');
     $app = JFactory::getApplication();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $model = $this->getModel();
     $lists = array();
     //get template data
     $template = $this->get('data');
     $isNew = $template->id < 1;
     // fail if checked out not by 'me'
     if ($model->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('COM_JOOMLEAGUE_ADMIN_TEMPLATE_THETEMPLATE'), $template->name);
         $app->redirect('index.php?option=' . $option, $msg);
     }
     $projectws = $this->get('Data', 'project');
     $templatepath = JPATH_COMPONENT_SITE . '/settings';
     $xmlfile = $templatepath . '/default/' . $template->template . '.xml';
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $extensiontpath = JPATH_COMPONENT_SITE . '/extensions/' . $extension;
         if (is_dir($extensiontpath . '/settings/default')) {
             if (file_exists($extensiontpath . '/settings/default/' . $template->template . '.xml')) {
                 $xmlfile = $extensiontpath . '/settings/default/' . $template->template . '.xml';
             }
         }
     }
     $form = JForm::getInstance($template->template, $xmlfile, array('control' => 'params'));
     $form->bind($template->params);
     $master_id = $projectws->master_template ? $projectws->master_template : '-1';
     $templates = array();
     //$templates[]=JHtml::_('select.option','0',JText::_('COM_JOOMLEAGUE_ADMIN_TEMPLATE_OTHER_TEMPLATE' ),'value','text');
     if ($res = $model->getAllTemplatesList($projectws->id, $master_id)) {
         $templates = array_merge($templates, $res);
     }
     $lists['templates'] = JHtmlSelect::genericlist($templates, 'select_id', 'class="inputbox" size="1" onchange="javascript: Joomla.submitbutton(\'template.apply\');"', 'value', 'text', $template->id);
     unset($res);
     unset($templates);
     $this->request_url = $uri->toString();
     $this->template = $template;
     $this->form = $form;
     $this->project = $projectws;
     $this->lists = $lists;
     $this->user = $user;
     $this->addToolbar();
     parent::display($tpl);
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:50,代码来源:view.html.php

示例7: ucfirst

 /**
  * get an instance of class corresponding to type
  * @param string class
  * @return object
  */
 function &getInstance($class)
 {
     $classname = 'JLGStatistic' . ucfirst($class);
     // check for statistic in extensions
     $extensions = JoomleagueHelper::getExtensions(0);
     foreach ($extensions as $type) {
         $file = JLG_PATH_SITE . DS . 'extensions' . DS . $type . DS . 'admin' . DS . 'statistics' . DS . $class . '.php';
         if (file_exists($file)) {
             require_once $file;
             $stat = new $classname();
             return $stat;
         }
     }
     if (!class_exists($classname)) {
         $file = JLG_PATH_ADMIN . DS . 'statistics' . DS . $class . '.php';
         if (!file_exists($file)) {
             JError::raiseError(0, $class . ': ' . JText::_('STATISTIC CLASS NOT DEFINED'));
         }
         require_once $file;
     }
     $stat = new $classname();
     return $stat;
 }
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:28,代码来源:base.php

示例8: getOptions

 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     //$filter = (string) $this->element['filter'];
     //$exclude = (string) $this->element['exclude'];
     //$hideNone = (string) $this->element['hide_none'];
     //$hideDefault = (string) $this->element['hide_default'];
     // Get the path in which to search for file options.
     $files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/statistics', 'php$');
     $options = array();
     foreach ($files as $file) {
         $parts = explode('.', $file);
         if ($parts[0] != 'base') {
             $options[] = JHtml::_('select.option', $parts[0], $parts[0]);
         }
     }
     // check for statistic in extensions
     $extensions = JoomleagueHelper::getExtensions(0);
     foreach ($extensions as $type) {
         $path = JLG_PATH_SITE . '/extensions/' . $type . '/admin/statistics';
         if (!file_exists($path)) {
             continue;
         }
         $files = JFolder::files($path, 'php$');
         foreach ($files as $file) {
             $parts = explode('.', $file);
             if ($parts[0] != 'base') {
                 $options[] = JHtml::_('select.option', $parts[0], $parts[0]);
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:42,代码来源:statstypelist.php

示例9: addTemplatePaths

 /**
  * static method which extends template path for given view names
  * Can be used by views to search for extensions that implement parts of common views
  * and add their path to the template search path.
  * (e.g. 'projectheading', 'backbutton', 'footer')
  * @param array(string) $viewnames, names of views for which templates need to be loaded,
  *                      so that extensions are used when available
  * @param JLGView       $view to which the template paths should be added
  */
 public static function addTemplatePaths($templatesToLoad, &$view)
 {
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($templatesToLoad as $template) {
         $view->addTemplatePath(JPATH_COMPONENT . '/views/' . $template . '/tmpl');
         if (is_array($extensions) && count($extensions) > 0) {
             foreach ($extensions as $e => $extension) {
                 $extension_views = JPATH_COMPONENT_SITE . '/extensions/' . $extension . '/views';
                 $tmpl_path = $extension_views . '/' . $template . '/tmpl';
                 if (JFolder::exists($tmpl_path)) {
                     $view->addTemplatePath($tmpl_path);
                 }
             }
         }
     }
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:25,代码来源:joomleaguehelper.php

示例10: array

        }
        if ($allowed) {
            echo '<tr><td><b><a href="' . $href . '" title="' . JText::_('JGLOBAL_AUTH_ACCESS_GRANTED') . '">' . $image . ' ' . $text . '</a></b></td></tr>';
        } else {
            echo '<tr><td><span title="' . JText::_('JGLOBAL_AUTH_ACCESS_DENIED') . '">' . $image . ' ' . $text . '</span></td></tr>';
        }
    }
    ?>
</table>
					</div>
					<?php 
    $n++;
}
echo JHTML::_('sliders.end');
//Extension
$extensions = JoomleagueHelper::getExtensions(1);
foreach ($extensions as $e => $extension) {
    $JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . DS . 'extensions' . DS . $extension;
    $menufile = $JLGPATH_EXTENSION . DS . 'admin' . DS . 'views' . DS . 'joomleague' . DS . 'tmpl' . DS . 'default_' . $extension . '.php';
    if (JFile::exists($menufile)) {
        echo $this->loadTemplate($extension);
    } else {
    }
}
?>
			<div style="text-align: center;"><br />
			<?php 
//			echo JHTML::_('image','administrator/components/com_joomleague/assets/images/jl.png',JText::_('JoomLeague'),array("title" => JText::_('JoomLeague')));
echo JHTML::_('image', 'administrator/components/com_joomleague/assets/images/jl-logo.png', JText::_('extended JoomLeague'), array("title" => JText::_('extended JoomLeague'), "width" => '150'));
?>
</div>
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:31,代码来源:default_admin.php

示例11: getInstance

 /**
  * get instance of ranking. Looks into extension folder too.
  *
  * @param string $type
  */
 public static function getInstance($project = null)
 {
     if ($project) {
         $extensions = JoomleagueHelper::getExtensions($project->id);
         foreach ($extensions as $type) {
             $classname = 'JLGRanking' . ucfirst($type);
             if (!class_exists($classname)) {
                 $file = JLG_PATH_SITE . '/extensions/' . $type . '/ranking.php';
                 if (file_exists($file)) {
                     require_once $file;
                     $obj = new $classname();
                     $obj->setProjectId($project->id);
                     return $obj;
                 }
             } else {
                 $obj = new $classname();
                 $obj->setProjectId($project->id);
                 return $obj;
             }
         }
         $obj = new JLGRanking();
         $obj->setProjectId($project->id);
         return $obj;
     }
     $obj = new JLGRanking();
     return $obj;
 }
开发者ID:Heart1010,项目名称:JoomLeague,代码行数:32,代码来源:ranking.php

示例12: checklist

 /**
  * check that all templates in default location have a corresponding record,except if project has a master template
  *
  */
 function checklist()
 {
     $mainframe =& JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $project_id = $this->_project_id;
     $defaultpath = JPATH_COMPONENT_SITE . DS . 'settings';
     // Get the views for this component.
     $path = JPATH_SITE . '/components/' . $option . '/views';
     $predictionTemplatePrefix = 'prediction';
     if (!$project_id) {
         return;
     }
     // get info from project
     $query = 'SELECT master_template,extension FROM #__joomleague_project WHERE id=' . (int) $project_id;
     $this->_db->setQuery($query);
     $params = $this->_db->loadObject();
     // if it's not a master template,do not create records.
     if ($params->master_template) {
         return true;
     }
     // otherwise,compare the records with the files
     // get records
     $query = 'SELECT template FROM #__joomleague_template_config WHERE project_id=' . (int) $project_id;
     $this->_db->setQuery($query);
     $records = $this->_db->loadResultArray();
     if (empty($records)) {
         $records = array();
     }
     // add default folder
     $xmldirs[] = $defaultpath . DS . 'default';
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $extensiontpath = JPATH_COMPONENT_SITE . DS . 'extensions' . DS . $extension;
         if (is_dir($extensiontpath . DS . 'settings' . DS . 'default')) {
             $xmldirs[] = $extensiontpath . DS . 'settings' . DS . 'default';
         }
     }
     // now check for all xml files in these folders
     foreach ($xmldirs as $xmldir) {
         if ($handle = opendir($xmldir)) {
             /* check that each xml template has a corresponding record in the
             			database for this project. If not,create the rows with default values
             			from the xml file */
             while ($file = readdir($handle)) {
                 if ($file != '.' && $file != '..' && $file != 'do_tipsl' && strtolower(substr($file, -3)) == 'xml' && strtolower(substr($file, 0, strlen($predictionTemplatePrefix))) != $predictionTemplatePrefix) {
                     $template = substr($file, 0, strlen($file) - 4);
                     // Determine if a metadata file exists for the view.
                     //$metafile = $path.'/'.$template.'/metadata.xml';
                     $metafile = $path . '/' . $template . '/tmpl/default.xml';
                     $attributetitle = '';
                     if (is_file($metafile)) {
                         // Attempt to load the xml file.
                         if ($metaxml = simplexml_load_file($metafile)) {
                             //$mainframe->enqueueMessage(JText::_('PredictionGame template metaxml-> '.'<br /><pre>~' . print_r($metaxml,true) . '~</pre><br />'),'');
                             // This will save the value of the attribute, and not the objet
                             //$attributetitle = (string)$metaxml->view->attributes()->title;
                             $attributetitle = (string) $metaxml->layout->attributes()->title;
                             //$mainframe->enqueueMessage(JText::_('PredictionGame template attribute-> '.'<br /><pre>~' . print_r($attributetitle,true) . '~</pre><br />'),'');
                             if ($menu = $metaxml->xpath('view[1]')) {
                                 $menu = $menu[0];
                                 //$mainframe->enqueueMessage(JText::_('PredictionGame template menu-> '.'<br /><pre>~' . print_r($menu,true) . '~</pre><br />'),'');
                             }
                         }
                     }
                     if (empty($records) || !in_array($template, $records)) {
                         $jRegistry = new JRegistry();
                         $form = JForm::getInstance($file, $xmldir . DS . $file);
                         $fieldsets = $form->getFieldsets();
                         foreach ($fieldsets as $fieldset) {
                             foreach ($form->getFieldset($fieldset->name) as $field) {
                                 $jRegistry->set($field->name, $field->value);
                             }
                         }
                         $defaultvalues = $jRegistry->toString('ini');
                         $tblTemplate_Config = JTable::getInstance('template', 'table');
                         $tblTemplate_Config->template = $template;
                         if ($attributetitle) {
                             $tblTemplate_Config->title = $attributetitle;
                         } else {
                             $tblTemplate_Config->title = $file;
                         }
                         $tblTemplate_Config->params = $defaultvalues;
                         $tblTemplate_Config->project_id = $project_id;
                         // Make sure the item is valid
                         if (!$tblTemplate_Config->check()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                         // Store the item to the database
                         if (!$tblTemplate_Config->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                         array_push($records, $template);
                     }
                 }
//.........这里部分代码省略.........
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:101,代码来源:templates.php

示例13: getExtended

 /**
  * support for extensions which can overload extended data
  * @param string $data
  * @param string $file
  * @return object
  */
 function getExtended($data = '', $file, $format = 'ini')
 {
     $xmlfile = JLG_PATH_ADMIN . '/assets/extended/' . $file . '.xml';
     //extension management
     $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
     foreach ($extensions as $e => $extension) {
         $JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . '/extensions/' . $extension . '/admin';
         //General extension extended xml
         $file = $JLGPATH_EXTENSION . '/assets/extended/' . $file . '.xml';
         if (file_exists(JPath::clean($file))) {
             $xmlfile = $file;
             break;
             //first extension file will win
         }
     }
     /*
      * extended data
      */
     $jRegistry = new JRegistry();
     $jRegistry->loadString($data, $format);
     $extended = JForm::getInstance('extended', $xmlfile, array('control' => 'extended'), false, '/config');
     $extended->bind($jRegistry);
     return $extended;
 }
开发者ID:Heart1010,项目名称:JoomLeague,代码行数:30,代码来源:jlgview.php

示例14: defined

/**
 * @see JLGView
 * @see JLGModel
 * @author		Wolfgang Pinitsch <andone@mfga.at>
 * @copyright	Copyright (C) 2005-2013 JoomLeague.net. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */
// no direct access
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$arrExtensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
$show_debug_info = JComponentHelper::getParams('com_joomleague')->get('show_debug_info', 0);
$model_pathes[] = array();
$view_pathes[] = array();
$lang = JFactory::getLanguage();
// diddipoeler
// normale extension anfang
for ($e = 0; $e < count($arrExtensions); $e++) {
    $extension = $arrExtensions[$e];
    $extensionpath = JLG_PATH_SITE . DS . 'extensions' . DS . $extension;
    // include file named after the extension for specific includes for examples
    if (file_exists($extensionpath . DS . $extension . '.php')) {
        //e.g example.php
        require_once $extensionpath . DS . $extension . '.php';
    }
    if ($app->isAdmin()) {
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:31,代码来源:extensions.php

示例15: checklist

 /**
  * check that all templates in default location have a corresponding record,except if project has a master template
  */
 function checklist()
 {
     $project_id = $this->_project_id;
     $defaultpath = JPATH_COMPONENT_SITE . '/settings';
     $predictionTemplatePrefix = 'prediction';
     if (!$project_id) {
         return;
     }
     // get info from project
     $query = 'SELECT master_template,extension FROM #__joomleague_project WHERE id=' . (int) $project_id;
     $this->_db->setQuery($query);
     $params = $this->_db->loadObject();
     // if it's not a master template,do not create records.
     if ($params->master_template) {
         return true;
     }
     // otherwise,compare the records with the files
     // get records
     $query = 'SELECT template FROM #__joomleague_template_config WHERE project_id=' . (int) $project_id;
     $this->_db->setQuery($query);
     $records = $this->_db->loadColumn();
     if (empty($records)) {
         $records = array();
     }
     // add default folder
     $xmldirs[] = $defaultpath . '/default';
     $extensions = JoomleagueHelper::getExtensions($this->input->getInt('p'));
     foreach ($extensions as $e => $extension) {
         $extensiontpath = JPATH_COMPONENT_SITE . '/extensions/' . $extension;
         if (is_dir($extensiontpath . '/settings/default')) {
             $xmldirs[] = $extensiontpath . '/settings/default';
         }
     }
     // now check for all xml files in these folders
     foreach ($xmldirs as $xmldir) {
         if ($handle = opendir($xmldir)) {
             /* check that each xml template has a corresponding record in the
             			database for this project. If not,create the rows with default values
             			from the xml file */
             while ($file = readdir($handle)) {
                 if ($file != '.' && $file != '..' && $file != 'do_tipsl' && strtolower(substr($file, -3)) == 'xml' && strtolower(substr($file, 0, strlen($predictionTemplatePrefix))) != $predictionTemplatePrefix) {
                     $template = substr($file, 0, strlen($file) - 4);
                     if (empty($records) || !in_array($template, $records)) {
                         $jRegistry = new JRegistry();
                         $form = JForm::getInstance($file, $xmldir . '/' . $file);
                         $fieldsets = $form->getFieldsets();
                         foreach ($fieldsets as $fieldset) {
                             foreach ($form->getFieldset($fieldset->name) as $field) {
                                 $jRegistry->set($field->name, $field->value);
                             }
                         }
                         $defaultvalues = $jRegistry->toString('ini');
                         $tblTemplate_Config = JTable::getInstance('Template', 'Table');
                         $tblTemplate_Config->template = $template;
                         $tblTemplate_Config->title = $file;
                         $tblTemplate_Config->params = $defaultvalues;
                         $tblTemplate_Config->project_id = $project_id;
                         // Make sure the item is valid
                         if (!$tblTemplate_Config->check()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                         // Store the item to the database
                         if (!$tblTemplate_Config->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                         array_push($records, $template);
                     }
                 }
             }
             closedir($handle);
         }
     }
 }
开发者ID:hfmprs,项目名称:JoomLeague,代码行数:78,代码来源:templates.php


注:本文中的JoomleagueHelper::getExtensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。