示例#1
0
 protected function getOptions()
 {
     $options = parent::getOptions();
     $paths = array();
     $paths[] = JPATH_ADMINISTRATOR . '/components/com_dpfields/models/types';
     if ($this->element['component']) {
         $paths[] = JPATH_ADMINISTRATOR . '/components/' . $this->element['component'] . '/models/types';
     }
     foreach ($paths as $path) {
         if (!JFolder::exists($path)) {
             continue;
         }
         // Looping trough the types
         foreach (JFolder::files($path, 'php', true, true) as $filePath) {
             $name = str_replace('.php', '', basename($filePath));
             if ($name == 'base') {
                 continue;
             }
             $label = 'COM_DPFIELDS_TYPE_' . strtoupper($name);
             if (!JFactory::getLanguage()->hasKey($label)) {
                 $label = JString::ucfirst($name);
             }
             $options[] = JHtml::_('select.option', $name, JText::_($label));
         }
     }
     return $options;
 }
示例#2
0
 /**
  * Ajax action called from element
  * 11/07/2011 - I've updated things so that any plugin ajax call uses 'view=plugin' rather than controller=plugin
  * this means that the controller used is now plugin.php and not plugin.raw.php
  *
  * @return  null
  */
 public function pluginAjax()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $plugin = $input->get('plugin', '');
     $method = $input->get('method', '');
     $group = $input->get('g', 'element');
     $pluginManager = FabrikWorker::getPluginManager();
     try {
         // First lets try the fabrik plugin manager - needed when loading namespaced plugins
         $pluginManager->loadPlugIn($plugin, $group);
     } catch (Exception $e) {
         if (!JPluginHelper::importPlugin('fabrik_' . $group, $plugin)) {
             $o = new stdClass();
             $o->err = 'unable to import plugin fabrik_' . $group . ' ' . $plugin;
             echo json_encode($o);
             return;
         }
     }
     if (substr($method, 0, 2) !== 'on') {
         $method = 'on' . JString::ucfirst($method);
     }
     $dispatcher = JEventDispatcher::getInstance();
     $dispatcher->trigger($method);
 }
示例#3
0
 /**
  * Ajax action called from element
  * 11/07/2011 - I've updated things so that any plugin ajax call uses 'view=plugin' rather than controller=plugin
  * this means that the controller used is now plugin.php and not plugin.raw.php
  *
  * @return  null
  */
 public function pluginAjax()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $plugin = $input->get('plugin', '');
     $method = $input->get('method', '');
     $group = $input->get('g', 'element');
     /**
      * $$$ hugh - playing around trying to fix a viz AJAX issue, figured we might need
      * to set up the dispatcher first and pass it to importPlugin, which doesn't hurt, but
      * didn't fix the issue.  But leaving these two lines, as I think this might be necessary
      * at some point, to get the methods into the dispatcher?
      *
      * $dispatcher = JDispatcher::getInstance();
      * if (!JPluginHelper::importPlugin('fabrik_'.$group, $plugin, true, $dispatcher))
      */
     if (!JPluginHelper::importPlugin('fabrik_' . $group, $plugin)) {
         $o = new stdClass();
         $o->err = 'unable to import plugin fabrik_' . $group . ' ' . $plugin;
         echo json_encode($o);
         return;
     }
     if (substr($method, 0, 2) !== 'on') {
         $method = 'on' . JString::ucfirst($method);
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger($method);
 }
示例#4
0
 function addAutoLoadViews($baseFolders, $format, $prefix = 'Xipt')
 {
     foreach (JFolder::folders($baseFolders) as $folder) {
         //e.g. XiController + Product
         $className = JString::ucfirst($prefix) . JString::ucfirst('View') . JString::ucfirst($folder);
         $fileName = JString::strtolower("view.{$format}.php");
         JLoader::register($className, $baseFolders . DS . $folder . DS . $fileName);
     }
 }
示例#5
0
 /**
  * constructor
  *
  * @access	protected
  * @param	string	The event handler
  */
 function __construct($eventHandlerName)
 {
     $eventListenerClassName = 'ARK' . JString::ucfirst($eventHandlerName) . 'ControllerListener';
     if (class_exists($eventListenerClassName)) {
         $this->_eventHandler = new $eventListenerClassName($this);
     } else {
         ARKHelper::error('No Event listener ' . $eventListenerClassName . ' class found.');
     }
 }
示例#6
0
 function buildTypes($value, $what)
 {
     $allValues = array();
     $callFunc = '_build' . JString::ucfirst($what);
     if (!method_exists(new XiptHelperProfiletypes(), $callFunc)) {
         XiptError::assert(0);
     }
     return XiptHelperProfiletypes::$callFunc($value);
 }
示例#7
0
 /**
  * constructor
  *
  * @access	protected
  * @param	string	The event handler
  */
 function __construct($eventHandlerName)
 {
     $eventListenerClassName = 'JCK' . JString::ucfirst($eventHandlerName) . 'ControllerListener';
     if (class_exists($eventListenerClassName)) {
         $this->_eventHandler = new $eventListenerClassName($this);
     } else {
         JError::raiseWarning(100, 'No Event listener ' . $eventListenerClassName . ' class found.');
     }
 }
示例#8
0
 public function store($updateNulls = false)
 {
     if (empty($this->value) && !empty($this->title)) {
         $this->value = JString::strtolower(JString::str_ireplace(' ', '', $this->title));
     }
     if (empty($this->title) && !empty($this->value)) {
         $this->title = JString::ucfirst($this->value);
     }
     return parent::store($updateNulls);
 }
示例#9
0
 public static function getInstance()
 {
     $suffix = JString::stristr(XiptHelperJomsocial::get_js_version(), 2.0) ? "Js20" : "Js18";
     $classname = "XiptFieldsTemplates" . JString::ucfirst($suffix);
     if (class_exists($classname, true) === false) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("{$className} : CLASS_NOT_FOUND"));
         return false;
     }
     $instance = new $classname();
     return $instance;
 }
示例#10
0
文件: video.php 项目: bizanto/Hooked
 /**
  * Load the object and the video provider as well 
  */
 public function load($oid = null)
 {
     if (parent::load($oid)) {
         // @todo: make sure loading is done ok
         $providerName = JString::strtolower($this->type);
         $libraryPath = COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'videos' . DS . $providerName . '.php';
         require_once $libraryPath;
         $className = 'CTableVideo' . JString::ucfirst($providerName);
         $this->_provider = new $className($this->_db);
         return true;
     }
     return false;
 }
示例#11
0
 /**
  * Loads in element's published validation objects
  *
  * @return  PlgFabrik_Validationrule[]	Validation objects
  */
 public function findAll()
 {
     if (isset($this->validations)) {
         return $this->validations;
     }
     $params = $this->elementModel->getParams();
     $validations = (array) $params->get('validations', 'array');
     $usedPlugins = (array) FArrayHelper::getValue($validations, 'plugin', array());
     $published = FArrayHelper::getValue($validations, 'plugin_published', array());
     $showIcon = FArrayHelper::getValue($validations, 'show_icon', array());
     $mustValidate = FArrayHelper::getValue($validations, 'must_validate', array());
     $validateIn = FArrayHelper::getValue($validations, 'validate_in', array());
     $validationOn = FArrayHelper::getValue($validations, 'validation_on', array());
     $mustValidate = FArrayHelper::getValue($validations, 'must_validate', array());
     $pluginManager = FabrikWorker::getPluginManager();
     $pluginManager->getPlugInGroup('validationrule');
     $c = 0;
     $this->validations = array();
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('fabrik_validationrule');
     $i = 0;
     foreach ($usedPlugins as $usedPlugin) {
         if ($usedPlugin !== '') {
             $isPublished = FArrayHelper::getValue($published, $i, true);
             if ($isPublished) {
                 $class = 'PlgFabrik_Validationrule' . JString::ucfirst($usedPlugin);
                 $conf = array();
                 $conf['name'] = JString::strtolower($usedPlugin);
                 $conf['type'] = JString::strtolower('fabrik_Validationrule');
                 /** @var PlgFabrik_Validationrule $plugIn */
                 $plugIn = new $class($dispatcher, $conf);
                 JPluginHelper::getPlugin('fabrik_validationrule', $usedPlugin);
                 $plugIn->elementModel = $this->elementModel;
                 $this->validations[] = $plugIn;
                 // Set params relative to plugin render order
                 $plugIn->setParams($params, $i);
                 $plugIn->getParams()->set('show_icon', FArrayHelper::getValue($showIcon, $i, true));
                 $plugIn->getParams()->set('validate_in', FArrayHelper::getValue($validateIn, $i, 'both'));
                 $plugIn->getParams()->set('validation_on', FArrayHelper::getValue($validationOn, $i, 'both'));
                 $plugIn->getParams()->set('must_validate', FArrayHelper::getValue($mustValidate, $i, '0'));
                 $plugIn->js();
                 $c++;
             }
         }
         $i++;
     }
     return $this->validations;
 }
示例#12
0
 /**
  * Means that any method in Fabrik 2, e.e. 'ajax_upload' should
  * now be changed to 'onAjax_upload'
  * ajax action called from element
  *
  * 11/07/2011 - ive updated things so that any plugin ajax call uses 'view=plugin' rather than controller=plugin
  * this means that the controller used is now plugin.php and not plugin.raw.php
  *
  * @return  null
  */
 public function pluginAjax()
 {
     $plugin = JRequest::getVar('plugin', '');
     $method = JRequest::getVar('method', '');
     $group = JRequest::getVar('g', 'element');
     if (!JPluginHelper::importPlugin('fabrik_' . $group, $plugin)) {
         $o = new stdClass();
         $o->err = 'unable to import plugin fabrik_' . $group . ' ' . $plugin;
         echo json_encode($o);
         return;
     }
     $dispatcher = JDispatcher::getInstance();
     if (substr($method, 0, 2) !== 'on') {
         $method = 'on' . JString::ucfirst($method);
     }
     $dispatcher->trigger($method);
 }
示例#13
0
	function getidvideo($providerName, $videoLink){
		$libraryPath	= JPATH_COMPONENT . DS . 'libraries' . DS . 'videos' . DS . $providerName . '.php';	

		jimport('joomla.filesystem.file');
		if (!JFile::exists($libraryPath)){	
			$redirect = JRoute::_('index.php?option=com_awdwall&&view=awdwall', false);
			$message	= JText::_('Video Provider is not supported');
			$mainframe->redirect($redirect , $message, 'error');
		}
		
		$db =& JFactory::getDBO();
		require_once($libraryPath);
		$className		= 'TableVideo' . JString::ucfirst($providerName);
		$videoObj		= new $className($db);
		$videoObj->init($videoLink);
		
		return $videoObj;
	}
示例#14
0
 /**
  * Means that any method in Fabrik 2, e.e. 'ajax_upload' should
  * now be changed to 'onAjax_upload'
  * ajax action called from element
  *
  * 11/07/2011 - I've updated things so that any plugin ajax call uses 'view=plugin' rather than controller=plugin
  * this means that the controller used is now plugin.php and not plugin.raw.php
  *
  * @return  null
  */
 public function pluginAjax()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $plugin = $input->get('plugin', '');
     $method = $input->get('method', '');
     $group = $input->get('g', 'element');
     if (!JPluginHelper::importPlugin('fabrik_' . $group, $plugin)) {
         $o = new stdClass();
         $o->err = 'unable to import plugin fabrik_' . $group . ' ' . $plugin;
         echo json_encode($o);
         return;
     }
     $dispatcher = JEventDispatcher::getInstance();
     if (substr($method, 0, 2) !== 'on') {
         $method = 'on' . JString::ucfirst($method);
     }
     $dispatcher->trigger($method);
 }
示例#15
0
 /**
  * @param  string $locType - cities, regions, countries, russia
  * @return string
  */
 public static function getLocations($locType)
 {
     $zoo = App::getInstance('zoo');
     $locations = self::apiRequest(array('method' => 'ems.get.locations', 'plain' => 'true', 'type' => $locType));
     $result = array('' => '- ' . JText::_('JBZOO_ELEMENT_SHIPPING_EMSPOST_' . $locType) . ' -');
     if (!$locations) {
         return $result;
     }
     $jbvars = $zoo->jbvars;
     foreach ($locations['locations'] as $location) {
         $value = $jbvars->lower($location['value']);
         $name = JString::ucfirst($jbvars->lower($location['name']));
         $result[$value] = $name;
     }
     if ($locType != 'russia') {
         asort($result);
     }
     return $result;
 }
示例#16
0
 public function init()
 {
     $plugin = JPluginHelper::getPlugin('editors', $this->_name);
     require_once JPATH_SITE . '/plugins/editors/' . $plugin->name . '/' . $plugin->name . '.php';
     $className = 'plgEditor' . JString::ucfirst($plugin->name);
     $editor = new $className($this, (array) $plugin);
     $onInit = $editor->onInit();
     if (empty($onInit)) {
         return '';
     }
     // We only need to fetch the script declarations since other scripts are already loaded
     $doc = new DOMDocument();
     $doc->loadHTML($onInit);
     $scripts = $doc->getElementsByTagName('script');
     $js = '';
     foreach ($scripts as $key => $script) {
         $js .= $scripts->item($key)->nodeValue;
     }
     return $js;
 }
示例#17
0
/**
 * This is the entry point for the AJAX calls.
 * We filter this out instead so that the AJAX methods can be called within the
 * controller.
 **/
function communityAjaxEntry($func, $args = null)
{
    // The first index will always be 'admin' to distinguish between admin ajax
    // calls and front end ajax calls.
    // $method[0]	= 'admin'
    // $method[1]	= CONTROLLER
    // $method[2]	= CONTROLLER->METHOD
    $calls = explode(',', $func);
    if (is_array($calls) && $calls[0] == 'admin') {
        $func = $_REQUEST['func'];
        $method = explode(',', $func);
        $controller = JString::strtolower($method[1]);
        require_once JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
        $controller = JString::ucfirst($controller);
        $controller = 'CommunityController' . $controller;
        $controller = new $controller();
        $output = call_user_func_array(array(&$controller, $method[2]), $args);
        return $output;
    }
}
示例#18
0
/**
 * This is the entry point for the AJAX calls.
 * We filter this out instead so that the AJAX methods can be called within the
 * controller.
 *
 * @param  string $func
 * @param  array  $args
 * @return mixed
 **/
function communityAjaxEntry($func, $args = null)
{
    // The first index will always be 'admin' to distinguish between admin ajax
    // calls and front end ajax calls.
    // $method[0]	= 'admin'
    // $method[1]	= CONTROLLER
    // $method[2]	= CONTROLLER->METHOD
    if (substr($func, 0, 5) === 'admin') {
        // @TODO: Not sure why we need to fetch ?func from REQUEST again.
        $func = $_REQUEST['func'];
        list($isAdmin, $controller, $method) = explode(',', $func);
        $controllerFile = JString::strtolower($controller);
        if (file_exists(JPATH_COMPONENT . '/controllers/' . $controllerFile . '.php')) {
            require_once JPATH_COMPONENT . '/controllers/' . $controllerFile . '.php';
            $controller = JString::ucfirst($controller);
            $controller = 'CommunityController' . $controller;
            $controller = new $controller();
            return call_user_func_array(array(&$controller, $method), $args);
        }
    }
}
示例#19
0
 static function getInstance($name, $type, $prefix = 'Xipt', $refresh = false)
 {
     static $instance = array();
     //generate class name
     $className = JString::ucfirst($prefix) . JString::ucfirst($type) . JString::ucfirst($name);
     // Clean the name
     $className = preg_replace('/[^A-Z0-9_]/i', '', $className);
     //if already there is an object
     if ($refresh === false && isset($instance[$className])) {
         return $instance[$className];
     }
     //class_exists function checks if class exist,
     // and also try auto-load class if it can
     if (class_exists($className, true) === false) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("CLASS_NOT_FOUND"), $className));
         return false;
     }
     //create new object, class must be autoloaded
     $instance[$className] = new $className();
     return $instance[$className];
 }
示例#20
0
 /**
  * Formats mail fields according to record types
  * @param $type
  * @param $extension
  * @param $data
  * @param $defaultSubject
  * @param $defaultBody
  */
 function prepareMailFields($type, $extension, $data, $defaultSubject = '', $defaultBody = '')
 {
     if (empty($data['records']) || !count($data['records'])) {
         $this->setError(JText::_('There are no records'));
         return false;
     }
     $record = reset($data['records']);
     if (empty($record->type)) {
         $this->setError(JText::_('Record type is not defined'));
         return false;
     }
     $result = null;
     $header = '<p>' . JText::_('This message was automatically generated by') . ' <a href="http://www.mightyextensions.com/joomla-components/defender-security-firewall">MightyDefender</a></p>';
     if ($record->type == 'file_integrity_php_jexec') {
         $files = array();
         foreach ($data['records'] as $rec) {
             $files[] = str_replace(JPATH_ROOT, '', $rec->url);
         }
         $result = new stdClass();
         $result->title = JString::ucfirst(JText::_($type)) . ': ' . $extension . '. ' . JText::_('Version') . ' ' . $data['meta']->version . ' by ' . htmlentities($data['info'][0], ENT_QUOTES, 'UTF-8');
         $result->subject = empty($defaultSubject) ? JText::_('Feedback') . '. ' . $result->title : $defaultSubject;
         $result->body = empty($defaultBody) ? JText::_('The following files are missing _JEXEC check: ') . '<br /><br />' . implode('<br />', $files) : $defaultBody;
         $result->body = $header . $result->body;
     }
     if ($record->type == 'file_integrity_php_bad_functions') {
         $files = array();
         foreach ($data['records'] as $rec) {
             $files[] = JText::_('File') . ': ' . str_replace(JPATH_ROOT, '', $rec->url) . ': <br />' . nl2br($rec->issue) . '<br />';
         }
         $result = new stdClass();
         $result->title = JString::ucfirst(JText::_($type)) . ': ' . $extension . '. ' . JText::_('Version') . ' ' . $data['meta']->version . ' by ' . htmlentities($data['info'][0], ENT_QUOTES, 'UTF-8');
         $result->subject = empty($defaultSubject) ? JText::_('Feedback') . '. ' . $result->title : $defaultSubject;
         $result->body = empty($defaultBody) ? JText::_('The following files contain functions, which may possibly cause security issues: ') . '<br /><br />' . implode('<br />', $files) : $defaultBody;
         $result->body = $header . $result->body;
     }
     return $result;
 }
示例#21
0
 /**
  * Get web service instance
  *
  * @param   array  $options  initial state options
  *
  * @throws Exception
  *
  * @return  FabrikWebService
  */
 public static function getInstance($options = array())
 {
     // Sanitize the database connector options.
     $options['driver'] = isset($options['driver']) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $options['driver']) : 'soap';
     $options['endpoint'] = isset($options['endpoint']) ? $options['endpoint'] : null;
     // Get the options signature for the database connector.
     $signature = md5(serialize($options));
     // If we already have a database connector instance for these options then just use that.
     if (empty(self::$instances[$signature])) {
         // Derive the class name from the driver.
         $class = 'FabrikWebService' . JString::ucfirst($options['driver']);
         // If the class doesn't exist, let's look for it and register it.
         if (!class_exists($class)) {
             // Derive the file path for the driver class.
             $path = dirname(__FILE__) . '/webservice/' . $options['driver'] . '.php';
             // If the file exists register the class with our class loader.
             if (file_exists($path)) {
                 JLoader::register($class, $path);
             } else {
                 throw new Exception(JText::sprintf('JLIB_DATABASE_ERROR_LOAD_DATABASE_DRIVER', $options['driver']));
             }
         }
         // If the class still doesn't exist we have nothing left to do but throw an exception.  We did our best.
         if (!class_exists($class)) {
             throw new Exception(JText::sprintf('JLIB_DATABASE_ERROR_LOAD_DATABASE_DRIVER', $options['driver']));
         }
         // Create our new FabrikWebService connector based on the options given.
         try {
             $instance = new $class($options);
         } catch (Exception $e) {
             throw new Exception(JText::sprintf('JLIB_DATABASE_ERROR_CONNECT_DATABASE', $e->getMessage()));
         }
         // Set the new connector to the global instances based on signature.
         self::$instances[$signature] = $instance;
     }
     return self::$instances[$signature];
 }
示例#22
0
 /**
  * Creates an object of the given type.
  *
  * @param string $type
  * @param string $context
  *
  * @return DPFieldsTypeBase
  */
 public static function loadTypeObject($type, $context)
 {
     // Loading the class
     $class = 'DPFieldsType' . JString::ucfirst($type);
     if (class_exists($class)) {
         return new $class();
     }
     // Searching the file
     $paths = array(JPATH_ADMINISTRATOR . '/components/com_dpfields/models/types');
     if ($context) {
         // Extracting the component and section
         $parts = self::extract($context);
         if ($parts) {
             $component = $parts[0];
             $paths[] = JPATH_ADMINISTRATOR . '/components/' . $component . '/models/types';
         }
     }
     // Search for the file and load it
     $file = JPath::find($paths, $type . '.php');
     if ($file !== false) {
         require_once $file;
     }
     return class_exists($class) ? new $class() : false;
 }
示例#23
0
 /**
  * Load a class for one of the form's entities of a particular type.
  * Currently, it makes sense to use this method for the "field" and "rule" entities
  * (but you can support more entities in your subclass).
  *
  * @param   string  $entity  One of the form entities (field or rule).
  * @param   string  $type    Type of an entity.
  *
  * @return  mixed  Class name on success or false otherwise.
  *
  * @since   11.1
  */
 protected static function loadClass($entity, $type)
 {
     if (strpos($type, '.')) {
         list($prefix, $type) = explode('.', $type);
     } else {
         $prefix = 'J';
     }
     $class = JString::ucfirst($prefix, '_') . 'Form' . JString::ucfirst($entity, '_') . JString::ucfirst($type, '_');
     if (class_exists($class)) {
         return $class;
     }
     // Get the field search path array.
     $paths = self::addPath($entity);
     // If the type is complex, add the base type to the paths.
     if ($pos = strpos($type, '_')) {
         // Add the complex type prefix to the paths.
         for ($i = 0, $n = count($paths); $i < $n; $i++) {
             // Derive the new path.
             $path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
             // If the path does not exist, add it.
             if (!in_array($path, $paths)) {
                 array_unshift($paths, $path);
             }
         }
         // Break off the end of the complex type.
         $type = substr($type, $pos + 1);
     }
     // Try to find the class file.
     $type = strtolower($type) . '.php';
     foreach ($paths as $path) {
         if ($file = self::find($path, $type)) {
             require_once $file;
             if (class_exists($class)) {
                 break;
             }
         }
     }
     // Check for all if the class exists.
     return class_exists($class) ? $class : false;
 }
 /**
  * Method to add alternative meta tags for associated menu items.
  *
  * @return  void
  *
  * @since   1.7
  */
 public function onAfterDispatch()
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $menu = $app->getMenu();
     $server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
     $option = $app->input->get('option');
     $eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
     if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
         // Get active menu item.
         $active = $menu->getActive();
         // Load menu associations.
         if ($active) {
             // Get menu item link.
             if ($app->get('sef')) {
                 $active_link = JRoute::_('index.php?Itemid=' . $active->id, false);
             } else {
                 $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
             }
             if ($active_link == JUri::base(true) . '/') {
                 $active_link .= 'index.php';
             }
             // Get current link.
             $current_link = JUri::getInstance()->toString(array('path', 'query'));
             if ($current_link == JUri::base(true) . '/') {
                 $current_link .= 'index.php';
             }
             // Check the exact menu item's URL.
             if ($active_link == $current_link) {
                 $associations = MenusHelper::getAssociations($active->id);
                 unset($associations[$active->language]);
             }
         }
         // Load component associations.
         $cName = JString::ucfirst($eName . 'HelperAssociation');
         JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
         if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
             $cassociations = call_user_func(array($cName, 'getAssociations'));
             $lang_code = $app->input->cookie->getString(JApplication::getHash('language'));
             // No cookie - let's try to detect browser language or use site default.
             if (!$lang_code) {
                 if ($this->params->get('detect_browser', 1)) {
                     $lang_code = JLanguageHelper::detectLanguage();
                 } else {
                     $lang_code = self::$default_lang;
                 }
             }
             unset($cassociations[$lang_code]);
         }
         // Handle the default associations.
         if ((!empty($associations) || !empty($cassociations)) && $this->params->get('item_associations')) {
             foreach (JLanguageHelper::getLanguages() as $language) {
                 if (!JLanguage::exists($language->lang_code)) {
                     continue;
                 }
                 if (isset($cassociations[$language->lang_code])) {
                     $link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef);
                     $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                 } elseif (isset($associations[$language->lang_code])) {
                     $item = $menu->getItem($associations[$language->lang_code]);
                     if ($item) {
                         if ($app->get('sef')) {
                             $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
                         } else {
                             $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                         }
                         $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                     }
                 }
             }
         } elseif ($active && $active->home) {
             foreach (JLanguageHelper::getLanguages() as $language) {
                 if (!JLanguage::exists($language->lang_code)) {
                     continue;
                 }
                 $item = $menu->getDefault($language->lang_code);
                 if ($item && $item->language != $active->language && $item->language != '*') {
                     if ($app->get('sef')) {
                         $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
                     } else {
                         $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                     }
                     $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                 }
             }
         }
     }
 }
示例#25
0
 /**
  * Method to add alternative meta tags for associated menu items.
  *
  * @return  void
  *
  * @since   1.7
  */
 public function onAfterDispatch()
 {
     $doc = JFactory::getDocument();
     if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
         $languages = $this->lang_codes;
         $homes = JLanguageMultilang::getSiteHomePages();
         $menu = $this->app->getMenu();
         $active = $menu->getActive();
         $levels = JFactory::getUser()->getAuthorisedViewLevels();
         $remove_default_prefix = $this->params->get('remove_default_prefix', 0);
         $server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
         $is_home = false;
         if ($active) {
             $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
             $current_link = JUri::getInstance()->toString(array('path', 'query'));
             // Load menu associations
             if ($active_link == $current_link) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
             // Check if we are on the homepage
             $is_home = $active->home && ($active_link == $current_link || $active_link == $current_link . 'index.php' || $active_link . '/' == $current_link);
         }
         // Load component associations.
         $option = $this->app->input->get('option');
         $cName = JString::ucfirst(JString::str_ireplace('com_', '', $option)) . 'HelperAssociation';
         JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
         if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
             $cassociations = call_user_func(array($cName, 'getAssociations'));
         }
         // For each language...
         foreach ($languages as $i => &$language) {
             switch (true) {
                 // Language without frontend UI || Language without specific home menu || Language without authorized access level
                 case !array_key_exists($i, JLanguageMultilang::getSiteLangs()):
                 case !isset($homes[$i]):
                 case isset($language->access) && $language->access && !in_array($language->access, $levels):
                     unset($languages[$i]);
                     break;
                     // Home page
                 // Home page
                 case $is_home:
                     $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $homes[$i]->id);
                     break;
                     // Current language link
                 // Current language link
                 case $i == $this->current_lang:
                     $language->link = JUri::getInstance()->toString(array('path', 'query'));
                     break;
                     // Component association
                 // Component association
                 case isset($cassociations[$i]):
                     $language->link = JRoute::_($cassociations[$i] . '&lang=' . $language->sef);
                     break;
                     // Menu items association
                     // Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
                 // Menu items association
                 // Heads up! "$item = $menu" here below is an assignment, *NOT* comparison
                 case isset($associations[$i]) && ($item = $menu->getItem($associations[$i])):
                     $language->link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                     break;
                     // Too bad...
                 // Too bad...
                 default:
                     unset($languages[$i]);
             }
         }
         // If there are at least 2 of them, add the rel="alternate" links to the <head>
         if (count($languages) > 1) {
             // Remove the sef from the default language if "Remove URL Language Code" is on
             if (isset($languages[$this->default_lang]) && $remove_default_prefix) {
                 $languages[$this->default_lang]->link = preg_replace('|/' . $languages[$this->default_lang]->sef . '/|', '/', $languages[$this->default_lang]->link, 1);
             }
             foreach ($languages as $i => &$language) {
                 $doc->addHeadLink($server . $language->link, 'alternate', 'rel', array('hreflang' => $i));
             }
             // Add x-default language tag
             if ($this->params->get('xdefault', 1)) {
                 $xdefault_language = $this->params->get('xdefault_language', $this->default_lang);
                 $xdefault_language = $xdefault_language == 'default' ? $this->default_lang : $xdefault_language;
                 if (isset($languages[$xdefault_language])) {
                     // Use a custom tag because addHeadLink is limited to one URI per tag
                     $doc->addCustomTag('<link href="' . $server . $languages[$xdefault_language]->link . '" rel="alternate" hreflang="x-default" />');
                 }
             }
         }
     }
 }
示例#26
0
/**
 * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component
 * @package     jbzoo
 * @version     2.x Pro
 * @author      JBZoo App http://jbzoo.com
 * @copyright   Copyright (C) JBZoo.com,  All rights reserved.
 * @license     http://jbzoo.com/license-pro.php JBZoo Licence
 * @coder       Alexander Oganov <*****@*****.**>
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$jbPrice = $element->getJBPrice();
$name = JText::_($element->getName());
$type = JString::strtolower($element->getElementType());
$desc = JString::trim($element->getDescription());
$classes = array('variant-param', 'jbprice-' . $jbPrice->getElementType(), ($element->isCore() ? 'core' : 'simple') . '-param', 'variant-' . $type . '-wrap');
$isRequired = (int) $element->config->get('required', 0);
// create required mark
$required = '';
if ($isRequired) {
    $required = '<span class="hasTip jbrequired-note" title="Param is required">*</span>';
    $classes[] = 'jbparam-required';
}
// create label
$name = isset($params['altlabel']) ? $params['altlabel'] : $name;
$desc = !empty($desc) ? $desc : JText::_('JBZOO_ELEMENT_PRICE_' . $type . '_DESC');
$label = '<strong class="label row-field">' . '<span class="hasTip jbparam-label" title="' . $desc . '">' . JString::ucfirst($name) . '</span>' . $required . '</strong>';
//create attributes for main div
$attributes = array('class' => $classes);
// render element
echo '<div ' . $this->app->jbhtml->buildAttrs($attributes) . '>' . $label . '<span class="attention jsMessage"></span>' . $element->edit($params) . '</div>';
示例#27
0
文件: field.php 项目: adjaika/J3Base
 /**
  * Method to instantiate the form field object.
  *
  * @param   JForm  $form  The form to attach to the form field object.
  *
  * @since   11.1
  */
 public function __construct($form = null)
 {
     // If there is a form passed into the constructor set the form and form control properties.
     if ($form instanceof JForm) {
         $this->form = $form;
         $this->formControl = $form->getFormControl();
     }
     // Detect the field type if not set
     if (!isset($this->type)) {
         $parts = JStringNormalise::fromCamelCase(get_called_class(), true);
         if ($parts[0] == 'J') {
             $this->type = JString::ucfirst($parts[count($parts) - 1], '_');
         } else {
             $this->type = JString::ucfirst($parts[0], '_') . JString::ucfirst($parts[count($parts) - 1], '_');
         }
     }
 }
示例#28
0
    $controller = explode('.', JRequest::getCmd('task'));
    $controller = array_shift($controller);
    $classname = 'FabrikController' . JString::ucfirst($controller);
    $path = JPATH_COMPONENT . '/controllers/' . $controller . '.php';
    if (JFile::exists($path)) {
        require_once $path;
        // Needed to process J content plugin (form)
        JRequest::setVar('view', $controller);
        $task = explode('.', JRequest::getCmd('task'));
        $task = array_pop($task);
        $controller = new $classname();
    } else {
        $controller = JController::getInstance('Fabrik');
    }
} else {
    $classname = 'FabrikController' . JString::ucfirst($controller);
    $controller = new $classname();
    $task = JRequest::getCmd('task');
}
if ($isplugin) {
    // Add in plugin view
    $controller->addViewPath(JPATH_SITE . '/plugins/fabrik_' . $type . '/' . $name . '/views');
    // Add the model path
    $modelpaths = JModel::addIncludePath(JPATH_SITE . '/plugins/fabrik_' . $type . '/' . $name . '/models');
}
$app = JFactory::getApplication();
$package = JRequest::getVar('package', 'fabrik');
$app->setUserState('com_fabrik.package', $package);
// Web service testing
JLoader::import('webservice', JPATH_SITE . '/components/com_fabrik/models/');
if (JRequest::getVar('soap') == 1) {
示例#29
0
 /**
  * Load a class for one of the form's entities of a particular type.
  * Currently, it makes sense to use this method for the "field" and "rule" entities
  * (but you can support more entities in your subclass).
  *
  * @param   string  $entity  One of the form entities (field or rule).
  * @param   string  $type    Type of an entity.
  *
  * @return  mixed  Class name on success or false otherwise.
  *
  * @since   2.0
  */
 public static function loadClass($entity, $type)
 {
     if (strpos($type, '.')) {
         list($prefix, $type) = explode('.', $type);
         $altPrefix = $prefix;
     } else {
         $prefix = 'FOF';
         $altPrefix = 'J';
     }
     $class = JString::ucfirst($prefix, '_') . 'Form' . JString::ucfirst($entity, '_') . JString::ucfirst($type, '_');
     $altClass = JString::ucfirst($altPrefix, '_') . 'Form' . JString::ucfirst($entity, '_') . JString::ucfirst($type, '_');
     if (class_exists($class)) {
         return $class;
     } elseif (class_exists($altClass)) {
         return $altClass;
     }
     // Get the field search path array.
     $paths = self::addPath($entity);
     // If the type is complex, add the base type to the paths.
     if ($pos = strpos($type, '_')) {
         // Add the complex type prefix to the paths.
         for ($i = 0, $n = count($paths); $i < $n; $i++) {
             // Derive the new path.
             $path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
             // If the path does not exist, add it.
             if (!in_array($path, $paths)) {
                 $paths[] = $path;
             }
         }
         // Break off the end of the complex type.
         $type = substr($type, $pos + 1);
     }
     // Try to find the class file.
     $type = strtolower($type) . '.php';
     $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
     foreach ($paths as $path) {
         if ($file = $filesystem->pathFind($path, $type)) {
             require_once $file;
             if (class_exists($class)) {
                 break;
             } elseif (class_exists($altClass)) {
                 break;
             }
         }
     }
     // Check for all if the class exists.
     if (class_exists($class)) {
         return $class;
     } elseif (class_exists($altClass)) {
         return $altClass;
     } else {
         return false;
     }
 }
示例#30
0
 public static function _callFunction($controller, $method, $arguments)
 {
     require_once JPATH_ROOT . '/components/com_community/controllers/controller.php';
     require_once JPATH_ROOT . '/components/com_community/controllers' . '/' . JString::strtolower($controller) . '.php';
     $controller = JString::ucfirst($controller);
     $controller = 'Community' . $controller . 'Controller';
     $controller = new $controller();
     // @rule: If method not exists, we need to do some assertion here.
     if (!method_exists($controller, $method)) {
         JError::raiseError(500, JText::_('Method not found'));
     }
     return call_user_func_array(array($controller, $method), $arguments);
 }