/** * Returns a reference to the a Table object, always creating it * * @param type $type The table type to instantiate * @param string A prefix for the table class name * @return database A database object * @since 1.5 */ function &getInstanceAutofields($type, $prefix, $table, $key = 'id', $defaults = array()) { $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); if (!class_exists($tableClass)) { jimport('joomla.filesystem.path'); if ($path = JPath::find(RdbsTable::addIncludePath(), strtolower($type) . '.php')) { require_once $path; if (!class_exists($tableClass)) { $tableClass = 'RdbsTable'; } } else { $tableClass = 'RdbsTable'; } } $db =& RdbsFactory::getDBO(); $instance = new $tableClass($table, $key, $db); $instance->setDBO($db); // get the table properties $result = $db->getTableFields(array($table)); $fields = $result[$table]; foreach ($fields as $key => $val) { if (count($defaults) != 0 and array_key_exists($key, $defaults)) { $instance->set($key, $defaults[$key]); } else { if (strpos($val, 'int') === false and strpos($val, 'float') === false) { $instance->set($key, ''); } else { $instance->set($key, 0); } } } return $instance; }
/** * * Enter description here ... * @param JForm $form * @param unknown $data */ function onContentPrepareForm($form, $data) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $this->template = $this->getTemplateName(); if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) { jimport('joomla.filesystem.path'); //JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params'); $plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml'); $tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml'); if (!$plg_file) { return false; } if ($tpl_file) { $form->loadFile($plg_file, false, '//form'); $form->loadFile($tpl_file, false, '//config'); } else { $form->loadFile($plg_file, false, '//form'); } if ($app->isSite()) { $jmstorage_fields = $form->getFieldset('jmstorage'); foreach ($jmstorage_fields as $name => $field) { $form->removeField($name, 'params'); } $form->removeField('config', 'params'); } if ($app->isAdmin()) { $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}'); } } }
/** * 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); }
/** * Load a template file -- first look in the templates folder for an override * * @param string The name of the template source file ... * automatically searches the template paths and compiles as needed. * @param string The name of the layout... * null or absent - use current layout (don't change behavior), * '' - no layout prefix in the name of file * not empty string - uses specified layout. * * @return string The output of the the template script. * @since 1.0 */ public function loadTemplate($tpl = null, $layout = null) { if (!is_string($layout)) { return parent::loadTemplate($tpl); } // clear prior output $this->_output = null; $template = JFactory::getApplication()->getTemplate(); $layoutTemplate = $this->getLayoutTemplate(); if ($layout == '') { if (empty($tpl)) { return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file)); } else { $file = $tpl; } } else { //create the template file name based on the layout $file = isset($tpl) ? $layout . '_' . $tpl : $layout; } // clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; // Load the language file for the template $lang = JFactory::getLanguage(); $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, false) || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", $lang->getDefault(), false, false); // change the template folder if alternative layout is in different template if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) { $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']); } // load the template script jimport('joomla.filesystem.path'); $filetofind = $this->_createFileName('template', array('name' => $file)); $this->_template = JPath::find($this->_path['template'], $filetofind); // If alternate layout can't be found, fall back to default layout if ($this->_template == false) { $filetofind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($this->_path['template'], $filetofind); } if ($this->_template != false) { // unset so as not to introduce into template scope unset($tpl); unset($file); // never allow a 'this' property if (isset($this->this)) { unset($this->this); } // start capturing output into a buffer ob_start(); // include the requested template filename in the local scope // (this will execute the view logic). include $this->_template; // done with the requested template; get the buffer and // clear it. $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; } else { return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file)); } }
/** * Method to finds the full real file path, checking possible overrides * * @return string The full path to the layout file * * @since 3.0 */ protected function getPath() { JLoader::import('joomla.filesystem.path'); if (is_null($this->fullPath) && !empty($this->layoutId)) { $this->addDebugMessage('<strong>Layout:</strong> ' . $this->layoutId); /* * Refresh paths - override is due to this line * -commenting out to stop default paths being re-instated in render() * * $this->refreshIncludePaths(false); */ $this->addDebugMessage('<strong>Include Paths:</strong> ' . print_r($this->includePaths, true)); $suffixes = $this->options->get('suffixes', array()); // Search for suffixed versions. Example: tags.j31.php if (!empty($suffixes)) { $this->addDebugMessage('<strong>Suffixes:</strong> ' . print_r($suffixes, true)); foreach ($suffixes as $suffix) { $rawPath = str_replace('.', '/', $this->layoutId) . '.' . $suffix . '.php'; $this->addDebugMessage('<strong>Searching layout for:</strong> ' . $rawPath); if ($this->fullPath = JPath::find($this->includePaths, $rawPath)) { $this->addDebugMessage('<strong>Found layout:</strong> ' . $this->fullPath); return $this->fullPath; } } } // Standard version $rawPath = str_replace('.', '/', $this->layoutId) . '.php'; $this->addDebugMessage('<strong>Searching layout for:</strong> ' . $rawPath); $this->fullPath = JPath::find($this->includePaths, $rawPath); if ($this->fullPath = JPath::find($this->includePaths, $rawPath)) { $this->addDebugMessage('<strong>Found layout:</strong> ' . $this->fullPath); } } return $this->fullPath; }
/** * Returns a reference to the a Table object, always creating it * * @param type $type The table type to instantiate * @param string $prefix A prefix for the table class name. Optional. * @param array $options Configuration array for model. Optional. * @return database A database object * @since 1.5 */ function &getInstance($type, $prefix = 'JTable', $config = array()) { $false = false; $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); if (!class_exists($tableClass)) { jimport('joomla.filesystem.path'); if ($path = JPath::find(JTable::addIncludePath(), strtolower($type) . '.php')) { require_once $path; if (!class_exists($tableClass)) { JError::raiseWarning(0, 'Table class ' . $tableClass . ' not found in file.'); return $false; } } else { JError::raiseWarning(0, 'Table ' . $type . ' not supported. File not found.'); return $false; } } //Make sure we are returning a DBO object if (array_key_exists('dbo', $config)) { $db =& $config['dbo']; } else { $db =& JFactory::getDBO(); } $instance = new $tableClass($db); //$instance->setDBO($db); return $instance; }
/** * Returns a reference to the a Helper object, only creating it if it doesn't already exist * * @param type $type The helper type to instantiate * @param string $prefix A prefix for the helper class name. Optional. * @return helper The Helper Object */ public static function getInstance($type = 'Base', $prefix = 'TiendaHelper') { //parent::getInstance( $type , $prefix ); static $instances; if (!isset($instances)) { $instances = array(); } $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); // The Base helper is in _base.php, but it's named TiendaHelperBase if (strtolower($type) == 'Base') { $helperClass = $prefix . ucfirst($type); $type = '_Base'; } $helperClass = $prefix . ucfirst($type); if (empty($instances[$helperClass])) { if (!class_exists($helperClass)) { jimport('joomla.filesystem.path'); if ($path = JPath::find(TiendaHelperBase::addIncludePath(), strtolower($type) . '.php')) { require_once $path; if (!class_exists($helperClass)) { JError::raiseWarning(0, 'Helper class ' . $helperClass . ' not found in file.'); return false; } } else { JError::raiseWarning(0, 'Helper ' . $type . ' not supported. File not found.'); return false; } } $instance = new $helperClass(); $instances[$helperClass] =& $instance; } return $instances[$helperClass]; }
/** * 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); }
/** * 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; }
public function setupTheme() { // Load our CSS and Javascript files if (!$this->isJFBConnectInstalled) { $this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/sc_bootstrap.css'); } $this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/common.css'); $paths = array(); $paths[] = JPATH_ROOT . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/mod_sclogin/themes/'; $paths[] = JPATH_ROOT . '/media/sourcecoast/themes/sclogin/'; $theme = $this->params->get('theme', 'default.css'); $file = JPath::find($paths, $theme); $file = str_replace(JPATH_SITE, '', $file); $file = str_replace('\\', "/", $file); //Windows support for file separators $this->doc->addStyleSheet(JURI::base(true) . $file); // Add placeholder Javascript for old browsers that don't support the placeholder field if ($this->user->guest) { jimport('joomla.environment.browser'); $browser = JBrowser::getInstance(); $browserType = $browser->getBrowser(); $browserVersion = $browser->getMajor(); if ($browserType == 'msie' && $browserVersion <= 9) { // Using addCustomTag to ensure this is the last section added to the head, which ensures that jfbcJQuery has been defined $this->doc->addCustomTag('<script src="' . JURI::base(true) . '/media/sourcecoast/js/jquery.placeholder.js" type="text/javascript"> </script>'); $this->doc->addCustomTag("<script>jfbcJQuery(document).ready(function() { jfbcJQuery('input').placeholder(); });</script>"); } } }
/** * Class loader method * * Additional arguments may be supplied and are passed to the sub-class. * Additional include paths are also able to be specified for third-party use * * @param string $key The name of helper method to load, (prefix).(class).function * prefix and class are optional and can be used to load custom * html helpers. * * @return mixed JHtml::call($function, $args) or False on error * * @since 1.0 * @throws InvalidArgumentException */ public static function _($key) { list($key, $prefix, $file, $func) = static::extract($key); if (array_key_exists($key, static::$registry)) { $function = static::$registry[$key]; $args = func_get_args(); // Remove function name from arguments array_shift($args); return static::call($function, $args); } $className = $prefix . ucfirst($file); if (!class_exists($className)) { $path = JPath::find(static::$includePaths, strtolower($file) . '.php'); if ($path) { require_once $path; if (!class_exists($className)) { throw new InvalidArgumentException(sprintf('%s not found.', $className), 500); } } else { throw new InvalidArgumentException(sprintf('%s %s not found.', $prefix, $file), 500); } } $toCall = array($className, $func); if (is_callable($toCall)) { static::register($key, $toCall); $args = func_get_args(); // Remove function name from arguments array_shift($args); return static::call($toCall, $args); } else { throw new InvalidArgumentException(sprintf('%s::%s not found.', $className, $func), 500); } }
/** * Returns a Controller object, always creating it * * @param string $type The contlorer type to instantiate * @param string $prefix Prefix for the controller class name. Optional. * @param array $config Configuration array for controller. Optional. * * @return mixed A model object or false on failure * * @since 1.1.0 */ public static function getInstance($type, $prefix = '', $config = array()) { // Check for array format. $filter = JFilterInput::getInstance(); $type = $filter->clean($type, 'cmd'); $prefix = $filter->clean($prefix, 'cmd'); $controllerClass = $prefix . ucfirst($type); if (!class_exists($controllerClass)) { if (!isset(self::$paths[$controllerClass])) { // Get the environment configuration. $basePath = JArrayHelper::getValue($config, 'base_path', JPATH_COMPONENT); $nameConfig = empty($type) ? array('name' => 'controller') : array('name' => $type, 'format' => JFactory::getApplication()->input->get('format', '', 'word')); // Define the controller path. $paths[] = $basePath . '/controllers'; $paths[] = $basePath; $path = JPath::find($paths, self::createFileName($nameConfig)); self::$paths[$controllerClass] = $path; // If the controller file path exists, include it. if ($path) { require_once $path; } } if (!class_exists($controllerClass)) { JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $controllerClass), JLog::WARNING, 'kextensions'); return false; } } return new $controllerClass($config); }
public function loadTemplate($tpl = null) { $this->_output = null; $template = JFactory::getApplication()->getTemplate(); $layout = $this->getLayout(); $layoutTemplate = $this->getLayoutTemplate(); $file = isset($tpl) ? $layout . '_' . $tpl : $layout; $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; $lang = JFactory::getLanguage(); $lang->load('tpl_' . $template, JPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, true); if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) { $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']); } jimport('joomla.filesystem.path'); $jversion_arr = explode(".", JVERSION); $priVersion = $jversion_arr[0]; $subVersion = $jversion_arr[1]; $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . $subVersion)); $this->_template = JPath::find($this->_path['template'], $fileToFind); if ($this->_template == false) { $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . 'x')); $this->_template = JPath::find($this->_path['template'], $fileToFind); } if ($this->_template == false) { $fileToFind = $this->_createFileName('template', array('name' => $file)); $this->_template = JPath::find($this->_path['template'], $fileToFind); } if ($this->_template == false) { $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . $subVersion . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($this->_path['template'], $fileToFind); if ($this->_template == false) { $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . 'x' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($this->_path['template'], $fileToFind); } if ($this->_template == false) { $fileToFind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($this->_path['template'], $fileToFind); } } if ($this->_template != false) { unset($tpl); unset($file); if (isset($this->this)) { unset($this->this); } ob_start(); include $this->_template; $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; } else { throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500); } }
public function getForm($data = array(), $loadData = true) { if ($data) { $data = (object) $data; } else { $data = $this->getItem(); } JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); JForm::addFieldPath(JPATH_COMPONENT . '/models/fields'); $style_xml_path = JPath::find(JForm::addFormPath(), strtolower('style') . '.xml'); $style_xml = JFactory::getXML($style_xml_path, true); if (isset($data->template_id) && $data->template_id) { $styleObject = JUDownloadFrontHelperTemplate::getTemplateStyleObject($data->id); $folder = $styleObject->folder; $folder = strtolower(str_replace(' ', '', $folder)); if ($folder) { $xml_file = JPath::clean(JPATH_SITE . "/components/com_judownload/templates/" . $folder . "/" . $folder . '.xml'); if (JFile::exists($xml_file)) { $xml = JFactory::getXML($xml_file); if ($xml->config) { foreach ($xml->config->children() as $child) { $style_params_xpath = $style_xml->xpath('//fieldset[@name="params"]'); JUDownloadHelper::appendXML($style_params_xpath[0], $child); } if ($xml->languages->count()) { foreach ($xml->languages->children() as $language) { $languageFile = (string) $language; $first_pos = strpos($languageFile, '.'); $last_pos = strrpos($languageFile, '.'); $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1); $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true); $path = isset($client->path) ? $client->path : JPATH_BASE; JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path); } } } } } } $form = $this->loadForm('com_judownload.style', $style_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } $app = JFactory::getApplication(); $id = $app->input->get('id', 0); if ($id) { $form->setFieldAttribute('template_id', 'disabled', 'true'); $form->setFieldAttribute('template_id', 'filter', 'unset'); if (isset($data->home) && $data->home == 1) { $form->setFieldAttribute('home', 'disabled', 'true'); } } return $form; }
/** * Gets the default template, searching for it in the * html/com_jsolrsearch/browse/ first, then loading the default.php * template from the extension's views/browse/tmpl folder. * * To override the default browse page, place a file called * <override>_<extension>.php in the html/com_jsolrsearch/browse/ directory, * where <override> is the name of the base layout you are overriding (in * most cases this will be "default"), and <extension> is the name of the * component whose data you are trying to browse. * * E.g. * * default_content.php */ private function _getDefaultTemplate() { $o = JFactory::getApplication()->input->get('o'); $extension = str_replace("com_", "", $o); $override = $this->getLayout() . '_' . $extension . '.php'; $themeOverridePath = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_jsolrsearch/browse'; if (JPath::find($themeOverridePath, $override)) { return $extension; } else { return null; } }
/** * Method to finds the full real file path, checking possible overrides * * @return string The full path to the layout file * * @since 3.0 */ protected function getPath() { static $fullPath = null; if (is_null($fullPath) && !empty($this->layoutId)) { $rawPath = str_replace('.', '/', $this->layoutId) . '.php'; $fileName = basename($rawPath); $filePath = dirname($rawPath); $possiblePaths = array(JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/' . $filePath, $this->basePath . '/' . $filePath); $fullPath = JPath::find($possiblePaths, $fileName); } return $fullPath; }
/** * * @staticvar array $instances * @param type $option * @param type $view * @param type $config * @return FOFToolbar */ public static function &getAnInstance($option = null, $config = array()) { static $instances = array(); // Make sure $config is an array if (is_object($config)) { $config = (array) $config; } elseif (!is_array($config)) { $config = array(); } $hash = $option; if (!array_key_exists($hash, $instances)) { if (array_key_exists('input', $config)) { if ($config['input'] instanceof FOFInput) { $input = $config['input']; } else { $input = new FOFInput($config['input']); } } else { $input = new FOFInput(); } $config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar'); $input->set('option', $config['option']); $config['input'] = $input; $className = ucfirst(str_replace('com_', '', $config['option'])) . 'Toolbar'; if (!class_exists($className)) { list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin(); if ($isAdmin) { $basePath = JPATH_ADMINISTRATOR; } elseif ($isCli) { $basePath = JPATH_ROOT; } else { $basePath = JPATH_SITE; } $searchPaths = array($basePath . '/components/' . $config['option'], $basePath . '/components/' . $config['option'] . '/toolbars', JPATH_ADMINISTRATOR . '/components/' . $config['option'], JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/toolbars'); if (array_key_exists('searchpath', $config)) { array_unshift($searchPaths, $config['searchpath']); } JLoader::import('joomla.filesystem.path'); $path = JPath::find($searchPaths, 'toolbar.php'); if ($path) { require_once $path; } } if (!class_exists($className)) { $className = 'FOFToolbar'; } $instance = new $className($config); $instances[$hash] = $instance; } return $instances[$hash]; }
function loadHelper($file = null) { if (function_exists($file) || class_exists($file)) { return true; } // load the template script jimport('joomla.filesystem.path'); $helper = JPath::find($this->_path['helper'], $this->_createFileName('helper', array('name' => $file))); if ($helper != false) { // include the requested template filename in the local scope include_once $helper; } return $helper; }
private function addTheme() { $paths = array(); $paths[] = JPATH_ROOT . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/com_jfbconnect/themes/scsocialstream/default/'; $paths[] = JPATH_ROOT . '/media/sourcecoast/themes/scsocialstream/default/'; $theme = 'styles.css'; $file = JPath::find($paths, $theme); $this->themeDir = str_replace("styles.css", "", $file); $file = str_replace(JPATH_SITE, '', $file); $file = str_replace('\\', "/", $file); //Windows support for file separators $document = JFactory::getDocument(); $document->addStyleSheet(JURI::base(true) . $file); }
public function findSnip($view, $file) { // Clear prior output $this->_output = null; $template = JFactory::getApplication()->getTemplate(); // Create the template file name based on the layout $file = "snippet" . $file; $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $paths = array(JPATH_ROOT . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_fss' . DS . $view); // Load the template script jimport('joomla.filesystem.path'); $this->_template = JPath::find($paths, $file); return $this->_template; }
/** * Loads a snippet from the snippets folder. Name can contain a slash: * foo/bar will load component/views/snippets/tmpl/foo/bar.php * * @param string $tpl * * @return string the output of the template * @throws Exception */ public function loadSnippet($tpl) { // Clear prior output $this->_output = null; // create a hash of the template to avoid conflicts with the array key in the cache $cacheKey = md5($tpl); // if the cache is not filled for the current template try to get it. if (!isset(self::$templateCache[$cacheKey])) { $baseDir = $this->_basePath . '/views/snippets/tmpl'; $component = JApplicationHelper::getComponentName(); $app = JFactory::getApplication(); $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); if ($this->_site_template != null) { $fallback = JPATH_SITE . '/templates/' . $this->_site_template . '/html/' . $component . '/' . 'snippets'; } else { $fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'snippets'; } $path = array($fallback, $baseDir); // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-\\/]/i', '', $tpl); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; // Load the template script jimport('joomla.filesystem.path'); $filetofind = $this->_createFileName('template', array('name' => $file)); self::$templateCache[$cacheKey] = JPath::find($path, $filetofind); } // get the template from the cache $template = self::$templateCache[$cacheKey]; // If alternate layout can't be found, fall back to default layout if ($template == false) { throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500); } // Unset so as not to introduce into template scope unset($tpl); unset($file); // Never allow a 'this' property if (isset($this->this)) { unset($this->this); } // Start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope // (this will execute the view logic). include $template; // Done with the requested template; get the buffer and // clear it. $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; }
/** * Returns a reference to a cache adapter object, always creating it * * @param string $type The cache object type to instantiate; default is output. * @param array $options Array of options * * @return JCache A JCache object * * @since 11.1 */ public static function getInstance($type = 'output', $options = array()) { JCacheController::addIncludePath(JPATH_PLATFORM . '/joomla/cache/controller'); $type = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $type)); $class = 'JCacheController' . ucfirst($type); if (!class_exists($class)) { // Search for the class file in the JCache include paths. jimport('joomla.filesystem.path'); if ($path = JPath::find(JCacheController::addIncludePath(), strtolower($type) . '.php')) { require_once $path; } else { JError::raiseError(500, 'Unable to load Cache Controller: ' . $type); } } return new $class($options); }
/** * Class loader method * * Additional arguments may be supplied and are passed to the sub-class. * Additional include paths are also able to be specified for third-party use * * @param string The name of helper method to load, (prefix).(class).function * prefix and class are optional and can be used to load custom * html helpers. */ function _($type) { //Initialise variables $prefix = 'XiptHtml'; $file = ''; $func = $type; $extraArgs = func_get_args(); // Check to see if we need to load a helper file $parts = explode('.', $type); switch (count($parts)) { case 3: $prefix = preg_replace('#[^A-Z0-9_]#i', '', $parts[0]); $file = preg_replace('#[^A-Z0-9_]#i', '', $parts[1]); $func = preg_replace('#[^A-Z0-9_]#i', '', $parts[2]); break; case 2: $file = preg_replace('#[^A-Z0-9_]#i', '', $parts[0]); $func = preg_replace('#[^A-Z0-9_]#i', '', $parts[1]); break; } $className = $prefix . ucfirst($file); if (!class_exists($className, true)) { jimport('joomla.filesystem.path'); $xiptHtmlPath = XIPT_FRONT_PATH_LIBRARY . DS . 'html'; if ($path = JPath::find(self::addIncludePath($xiptHtmlPath), strtolower($file) . '.php')) { require_once $path; //if class does not exist at our end then handle it by joomla //2nd argument true will autoload class if autoload concept exist if (!class_exists($className, true)) { return call_user_func_array(array('JHTML', '_'), $extraArgs); } } else { return call_user_func_array(array('JHTML', '_'), $extraArgs); } } if (is_callable(array($className, $func))) { $temp = func_get_args(); array_shift($temp); $args = array(); foreach ($temp as $k => $v) { $args[] =& $temp[$k]; } return call_user_func_array(array($className, $func), $args); } else { return call_user_func_array(array('JHTML', '_'), $extraArgs); } }
public function loadTemplate($tpl = null) { $this->_output = null; $template = JFactory::getApplication()->getTemplate(); $layout = $this->getLayout(); $layoutTemplate = $this->getLayoutTemplate(); $file = isset($tpl) ? $layout . '_' . $tpl : $layout; $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; $lang = JFactory::getLanguage(); $lang->load('tpl_' . $template, JPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, true); if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) { $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']); } jimport('joomla.filesystem.path'); $filetofind = $this->_createFileName('template', array('name' => $file)); $app = JFactory::getApplication(); $input = $app->input; $plugin_id = $input->getInt('id', 0); if ($plugin_id) { $model = $this->getModel(); $template = $model->getPluginTemplate($plugin_id); if ($template) { $this->_addPath('template', $template); } } $this->_template = JPath::find($this->_path['template'], $filetofind); if ($this->_template == false) { $filetofind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = JPath::find($this->_path['template'], $filetofind); } if ($this->_template != false) { unset($tpl); unset($file); if (isset($this->this)) { unset($this->this); } ob_start(); include $this->_template; $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; } else { return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file)); } }
/** * Class loader method * * Additional arguments may be supplied and are passed to the sub-class. * Additional include paths are also able to be specified for third-party use * * @param string The name of helper method to load, (prefix).(class).function * prefix and class are optional and can be used to load custom * html helpers. */ function _($type) { //Initialise variables $prefix = 'JHTML'; $file = ''; $func = $type; // Check to see if we need to load a helper file $parts = explode('.', $type); switch (count($parts)) { case 3: $prefix = preg_replace('#[^A-Z0-9_]#i', '', $parts[0]); $file = preg_replace('#[^A-Z0-9_]#i', '', $parts[1]); $func = preg_replace('#[^A-Z0-9_]#i', '', $parts[2]); break; case 2: $file = preg_replace('#[^A-Z0-9_]#i', '', $parts[0]); $func = preg_replace('#[^A-Z0-9_]#i', '', $parts[1]); break; } $className = $prefix . ucfirst($file); if (!class_exists($className)) { jimport('joomla.filesystem.path'); if ($path = JPath::find(JHTML::addIncludePath(), strtolower($file) . '.php')) { require_once $path; if (!class_exists($className)) { JError::raiseWarning(0, $className . '::' . $func . ' not found in file.'); return false; } } else { JError::raiseWarning(0, $prefix . $file . ' not supported. File not found.'); return false; } } if (is_callable(array($className, $func))) { $temp = func_get_args(); array_shift($temp); $args = array(); foreach ($temp as $k => $v) { $args[] =& $temp[$k]; } return call_user_func_array(array($className, $func), $args); } else { JError::raiseWarning(0, $className . '::' . $func . ' not supported.'); return false; } }
/** * Control Panel display function * * @param template $tpl */ function display($tpl = null) { $layout = $this->getLayout(); if (method_exists($this, $layout)) { $this->{$layout}($tpl); } // Allow the layout to be overriden by menu parameter - this only works if its valid for the task $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $newlayout = $params->getValue("overridelayout", $layout); // check the template layout is valid for this task jimport('joomla.filesystem.path'); $filetofind = $this->_createFileName('template', array('name' => $newlayout)); if (JPath::find($this->_path['template'], $filetofind)) { $this->setLayout($newlayout); } parent::display($tpl); }
/** * Gets an instance of a component's toolbar * * @param string $option The name of the component * @param array $config The configuration array for the component * * @return FOFToolbar The toolbar instance for the component */ public static function &getAnInstance($option = null, $config = array()) { static $instances = array(); // Make sure $config is an array if (is_object($config)) { $config = (array) $config; } elseif (!is_array($config)) { $config = array(); } $hash = $option; if (!array_key_exists($hash, $instances)) { if (array_key_exists('input', $config)) { if ($config['input'] instanceof FOFInput) { $input = $config['input']; } else { $input = new FOFInput($config['input']); } } else { $input = new FOFInput(); } $config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar'); $input->set('option', $config['option']); $config['input'] = $input; $className = ucfirst(str_replace('com_', '', $config['option'])) . 'Toolbar'; if (!class_exists($className)) { $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']); $searchPaths = array($componentPaths['main'], $componentPaths['main'] . '/toolbars', $componentPaths['alt'], $componentPaths['alt'] . '/toolbars'); if (array_key_exists('searchpath', $config)) { array_unshift($searchPaths, $config['searchpath']); } JLoader::import('joomla.filesystem.path'); $path = JPath::find($searchPaths, 'toolbar.php'); if ($path) { require_once $path; } } if (!class_exists($className)) { $className = 'FOFToolbar'; } $instance = new $className($config); $instances[$hash] = $instance; } return $instances[$hash]; }
/** * Class loader method * * Additional arguments may be supplied and are passed to the sub-class. * Additional include paths are also able to be specified for third-party use * * @param string The name of helper method to load, (prefix).(class).function * prefix and class are optional and can be used to load custom * html helpers. */ public static function _($type) { $type = preg_replace('#[^A-Z0-9_\\.]#i', '', $type); // Check to see if we need to load a helper file $parts = explode('.', $type); $prefix = count($parts) == 3 ? array_shift($parts) : 'JHtml'; $file = count($parts) == 2 ? array_shift($parts) : ''; $func = array_shift($parts); $key = strtolower($prefix . '.' . $file . '.' . $func); if (array_key_exists($key, self::$registry)) { $function = self::$registry[$key]; $args = func_get_args(); // remove function name from arguments array_shift($args); return JHtml::call($function, $args); } $className = $prefix . ucfirst($file); if (!class_exists($className)) { jimport('joomla.filesystem.path'); if ($path = JPath::find(JHtml::$includePaths, strtolower($file) . '.php')) { require_once $path; if (!class_exists($className)) { JError::raiseError(500, $className . '::' . $func . ' not found in file.'); return false; } } else { JError::raiseError(500, $prefix . $file . ' not supported. File not found.'); return false; } } $toCall = array($className, $func); if (is_callable($toCall)) { JHtml::register($key, $toCall); $args = func_get_args(); // remove function name from arguments array_shift($args); return JHtml::call($toCall, $args); } else { JError::raiseError(500, $className . '::' . $func . ' not supported.'); return false; } }
/** * Returns a reference to a cache adapter object, always creating it * * @param string $type The cache object type to instantiate; default is output. * @param array $options Array of options * * @return JCacheController * * @since 11.1 * @throws RuntimeException */ public static function getInstance($type = 'output', $options = array()) { self::addIncludePath(JPATH_PLATFORM . '/joomla/cache/controller'); $type = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $type)); $class = 'JCacheController' . ucfirst($type); if (!class_exists($class)) { // Search for the class file in the JCache include paths. jimport('joomla.filesystem.path'); $path = JPath::find(self::addIncludePath(), strtolower($type) . '.php'); if ($path === false) { throw new RuntimeException('Unable to load Cache Controller: ' . $type, 500); } JLoader::register($class, $path); // The class should now be loaded if (!class_exists($class)) { throw new RuntimeException('Unable to load Cache Controller: ' . $type, 500); } } return new $class($options); }
public function getForm($data = array(), $loadData = true) { if ($data) { $data = (object) $data; } else { $data = $this->getItem(); } JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); JForm::addFieldPath(JPATH_COMPONENT . '/models/fields'); $field_xml_path = JPath::find(JForm::addFormPath(), 'field.xml'); $field_xml = JFactory::getXML($field_xml_path, true); if ($data->plugin_id) { $db = JFactory::getDbo(); $query = 'SELECT folder, type' . ' FROM #__judirectory_plugins' . ' WHERE (id =' . $data->plugin_id . ')'; $db->setQuery($query); $pluginObj = $db->loadObject(); if ($pluginObj && $pluginObj->folder) { $folder = strtolower(str_replace(' ', '', $pluginObj->folder)); $xml_file = JPATH_SITE . "/components/com_judirectory/fields/" . $folder . "/" . $folder . '.xml'; if (JFile::exists($xml_file)) { $field_plugin_xml = JFactory::getXML($xml_file); if ($field_plugin_xml->config) { foreach ($field_plugin_xml->config->children() as $child) { $field_params_xpath = $field_xml->xpath('//fieldset[@name="params"]'); JUDirectoryHelper::appendXML($field_params_xpath[0], $child); } if ($field_plugin_xml->languages->count()) { foreach ($field_plugin_xml->languages->children() as $language) { $languageFile = (string) $language; $first_pos = strpos($languageFile, '.'); $last_pos = strrpos($languageFile, '.'); $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1); $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true); $path = isset($client->path) ? $client->path : JPATH_BASE; JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path); } } } } } } $form = $this->loadForm('com_judirectory.field', $field_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } $ignored_options = explode(",", $data->ignored_options); foreach ($ignored_options as $ignored_option) { $form->setFieldAttribute($ignored_option, 'disabled', 'true'); $form->setFieldAttribute($ignored_option, 'filter', 'unset'); } if (!$this->canEditState($data)) { $form->setFieldAttribute('ordering', 'disabled', 'true'); $form->setFieldAttribute('published', 'disabled', 'true'); $form->setFieldAttribute('ordering', 'filter', 'unset'); $form->setFieldAttribute('published', 'filter', 'unset'); } return $form; }