示例#1
0
 /**
  * Initializes the configuration for the object
  * 
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   array   Configuration settings
  */
 protected function _initialize(KConfig $config)
 {
     $language = JFactory::getLanguage();
     $settings = array('directionality' => $language->isRTL() ? 'rtl' : 'ltr', 'editor_selector' => 'editable', 'mode' => 'specific_textareas', 'skin' => 'nooku', 'theme' => 'advanced', 'inline_styles' => true, 'gecko_spellcheck' => true, 'entity_encoding' => 'raw', 'extended_valid_elements' => '', 'invalid_elements' => 'script,applet,iframe', 'relative_urls' => true, 'remove_script_host' => false, 'document_base_url' => KRequest::root(), 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_source_editor_height' => '550', 'height' => '550', 'width' => '100%', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => false, 'theme_advanced_resize_horizontal' => false, 'theme_advanced_path' => true, 'dialog_type' => 'modal', 'language' => substr($language->getTag(), 0, strpos($language->getTag(), '-')), 'theme_advanced_buttons1' => implode(',', array('bold', 'italic', 'strikethrough', 'underline', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'link', 'unlink', '|', 'spellchecker', 'fullscreen', 'image', 'readmore', 'article', '|', 'advanced')), 'theme_advanced_buttons2' => implode(',', array('formatselect', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo')), 'theme_advanced_buttons3' => '', 'theme_advanced_buttons4' => '');
     $config->append(array('layout' => 'default', 'media_url' => KRequest::root() . '/media'))->append(array('codemirror' => true, 'codemirrorOptions' => array('stylesheet' => array($config->media_url . '/com_editors/codemirror/css/xmlcolors.css', $config->media_url . '/com_editors/codemirror/css/jscolors.css', $config->media_url . '/com_editors/codemirror/css/csscolors.css', $config->media_url . '/com_editors/css/codemirror.css'), 'path' => $config->media_url . '/com_editors/codemirror/js/'), 'editor_settings' => $settings));
     parent::_initialize($config);
 }
示例#2
0
 public function __get($column)
 {
     if ($column == 'image_path') {
         return $this->image ? KRequest::root() . '/joomlatools-files/docman-images/' . $this->image : null;
     }
     if ($column == 'icon') {
         if (!is_object($this->params)) {
             $this->params = json_decode($this->params);
         }
         $icon = $this->params->icon ? $this->params->icon : 'icon:folder.png';
         return $icon;
     }
     if ($column == 'icon_path') {
         $icon = $this->icon;
         if (substr($icon, 0, 5) === 'icon:') {
             $icon = '/joomlatools-files/docman-icons/' . substr($icon, 5);
         } else {
             $icon = '/media/com_docman/images/icons/' . $icon;
         }
         return KRequest::root() . $icon;
     }
     if ($column === 'description_summary') {
         $description = $this->description;
         $position = strpos($description, '<hr id="system-readmore" />');
         if ($position !== false) {
             return substr($description, 0, $position);
         }
         return $description;
     }
     if ($column === 'description_full') {
         return str_replace('<hr id="system-readmore" />', '', $this->description);
     }
     return parent::__get($column);
 }
示例#3
0
 /**
  * Renders the html markup for the user avatar
  *
  * @author Stian Didriksen <*****@*****.**>
  * @return string
  */
 public function image($config = array())
 {
     $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams();
     $prepend = KFactory::get('lib.joomla.application')->isAdmin() ? KRequest::root() . '/' : '';
     $config = new KConfig($config);
     $config->append(array('id' => KFactory::get('admin::com.ninjaboard.model.people')->getMe()->id, 'thumbnail' => 'large', 'class' => 'avatar', 'link' => 'person', 'type' => 'css'));
     $person = KFactory::tmp('admin::com.ninjaboard.model.people')->id($config->id)->getItem();
     $avatar_on = new DateTime($person->avatar_on);
     $cache = (int) $avatar_on->format('U');
     $config->append(array('avatarurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=avatar&id=' . $config->id . '&thumbnail=' . $config->thumbnail . '&cache=' . $cache), 'profileurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=person&id=' . $config->id)));
     $attribs = array('class' => $config->class, 'href' => $config->profileurl);
     $height = $params['avatar_settings'][$config->thumbnail . '_thumbnail_height'];
     $width = $params['avatar_settings'][$config->thumbnail . '_thumbnail_width'];
     ///* @TODO Following is the <img /> version, likely going to be deprecated
     if ($config->type == 'tag') {
         $attribs['src'] = $config->avatarurl;
         $attribs['height'] = $height;
         $attribs['width'] = $width;
         unset($attribs['href']);
         $html = '<img ' . KHelperArray::toString($attribs) . ' />';
     } else {
         $style = 'background-image: url(' . $config->avatarurl . '); ';
         $style .= 'height: ' . $height . 'px; ';
         $style .= 'width: ' . $width . 'px;';
         $attribs['style'] = $style;
         $html = '<a ' . KHelperArray::toString($attribs) . '></a>';
     }
     return $html;
 }
示例#4
0
文件: koowa.php 项目: Roma48/mayak
 public function __construct($subject, $config = array())
 {
     // Turn off E_STRICT errors for now
     error_reporting(error_reporting() & ~E_STRICT);
     // Check if database type is MySQLi
     if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
         if (JFactory::getApplication()->getName() === 'administrator') {
             $string = version_compare(JVERSION, '1.6', '<') ? 'mysqli' : 'MySQLi';
             $link = JRoute::_('index.php?option=com_config');
             $error = 'In order to use Joomlatools framework, your database type in Global Configuration should be set to <strong>%1$s</strong>. Please go to <a href="%2$s">Global Configuration</a> and in the \'Server\' tab change your Database Type to <strong>%1$s</strong>.';
             JError::raiseWarning(0, sprintf(JText::_($error), $string, $link));
         }
         return;
     }
     // Set pcre.backtrack_limit to a larger value
     // See: https://bugs.php.net/bug.php?id=40846
     if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
         @ini_set('pcre.backtrack_limit', 1000000);
     }
     //Set constants
     define('KDEBUG', JDEBUG);
     //Set path definitions
     define('JPATH_FILES', JPATH_ROOT);
     define('JPATH_IMAGES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'images');
     //Set exception handler
     set_exception_handler(array($this, 'exceptionHandler'));
     // Koowa : setup
     require_once JPATH_LIBRARIES . '/koowa/koowa.php';
     Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
     KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
     KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
     KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
     KServiceIdentifier::setApplication('site', JPATH_SITE);
     KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
     KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
     KService::setAlias('translator', 'com:default.translator');
     //Setup the request
     if (JFactory::getApplication()->getName() !== 'site') {
         KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
     }
     //Load the koowa plugins
     JPluginHelper::importPlugin('koowa', null, true);
     //Bugfix : Set offset accoording to user's timezone
     if (!JFactory::getUser()->guest) {
         if ($offset = JFactory::getUser()->getParam('timezone')) {
             if (version_compare(JVERSION, '3.0', '>=')) {
                 JFactory::getConfig()->set('offset', $offset);
             } else {
                 JFactory::getConfig()->setValue('config.offset', $offset);
             }
         }
     }
     // Load language files for the framework
     KService::get('com:default.translator')->loadLanguageFiles();
     parent::__construct($subject, $config);
 }
示例#5
0
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     if (!$config->template_url) {
         $state = $this->getModel()->getState();
         $config->template_url = KRequest::root() . ($state->application == 'admininistrator' ? '/administrator' : '') . '/templates';
     }
     // Set base url used by things like template thumbnails
     $this->assign('templateurl', $config->template_url);
 }
示例#6
0
 public function __construct($subject, $config = array())
 {
     // Check if Koowa is active
     if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
         JError::raiseWarning(0, JText::_("Koowa plugin requires MySQLi Database Driver. Please change your database configuration settings to 'mysqli'"));
         return;
     }
     // Check for suhosin
     if (in_array('suhosin', get_loaded_extensions())) {
         //Attempt setting the whitelist value
         @ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://');
         //Checking if the whitelist is ok
         if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) {
             JError::raiseWarning(0, sprintf(JText::_('Your server has Suhosin loaded. Please follow <a href="%s" target="_blank">this</a> tutorial.'), 'https://nooku.assembla.com/wiki/show/nooku-framework/Known_Issues'));
             return;
         }
     }
     //Set constants
     define('KDEBUG', JDEBUG);
     define('JPATH_IMAGES', JPATH_ROOT . '/images');
     //Set exception handler
     set_exception_handler(array($this, 'exceptionHandler'));
     // Require the library loader
     JLoader::import('libraries.koowa.koowa', JPATH_ROOT);
     JLoader::import('libraries.koowa.loader.loader', JPATH_ROOT);
     //Setup the loader
     KLoader::addAdapter(new KLoaderAdapterKoowa(Koowa::getPath()));
     KLoader::addAdapter(new KLoaderAdapterJoomla(JPATH_LIBRARIES));
     KLoader::addAdapter(new KLoaderAdapterModule(JPATH_BASE));
     KLoader::addAdapter(new KLoaderAdapterPlugin(JPATH_ROOT));
     KLoader::addAdapter(new KLoaderAdapterComponent(JPATH_BASE));
     //Setup the factory
     KFactory::addAdapter(new KFactoryAdapterKoowa());
     KFactory::addAdapter(new KFactoryAdapterJoomla());
     KFactory::addAdapter(new KFactoryAdapterModule());
     KFactory::addAdapter(new KFactoryAdapterPlugin());
     KFactory::addAdapter(new KFactoryAdapterComponent());
     //Setup the identifier application paths
     KIdentifier::registerApplication('site', JPATH_SITE);
     KIdentifier::registerApplication('admin', JPATH_ADMINISTRATOR);
     //Setup the request
     KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
     //Set factory identifier aliasses
     KFactory::map('lib.koowa.database.adapter.mysqli', 'admin::com.default.database.adapter.mysqli');
     //Load the koowa plugins
     JPluginHelper::importPlugin('koowa', null, true, KFactory::get('lib.koowa.event.dispatcher'));
     //Bugfix : Set offset accoording to user's timezone
     if (!KFactory::get('lib.joomla.user')->guest) {
         if ($offset = KFactory::get('lib.joomla.user')->getParam('timezone')) {
             KFactory::get('lib.joomla.config')->setValue('config.offset', $offset);
         }
     }
     parent::__construct($subject, $config);
 }
示例#7
0
 public function notify(KCommandContext $context)
 {
     if ($context->result->status == KDatabase::STATUS_CREATED) {
         $application = JFactory::getApplication();
         // Send e-mail to the user.
         $mail_from_email = $application->getCfg('mailfrom');
         $mail_from_name = $application->getCfg('fromname');
         $mail_site_name = $application->getCfg('sitename');
         if ($mail_from_email == '' || $mail_from_name == '') {
             $user = JFactory::getUser();
             $mail_from_email = $user->email;
             $mail_from_name = $user->name;
         }
         $subject = JText::_('NEW_USER_MESSAGE_SUBJECT');
         $message = JText::sprintf('NEW_USER_MESSAGE', $context->result->name, $mail_site_name, KRequest::root(), $context->result->username, $context->result->password);
         JUtility::sendMail($mail_from_email, $mail_from_name, $context->result->email, $subject, $message);
     }
 }
示例#8
0
 public function getList()
 {
     //Removed by DC Oct 2010 to allow for multiple image pickers on one page
     //if(!isset($this->_list))
     //{
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     // path to images directory
     $identifier = $this->getIdentifier();
     $path = $this->_state->folder;
     $filter = '\\.png$|\\.gif$|\\.jpg$|\\.bmp$|\\.ico$';
     $uripath = str_replace(JPATH_ROOT, KRequest::root(), $path);
     //Added by DC Oct 2010 to allow for multiple image pickers on one page
     $this->_images = array();
     $root = basename($path);
     if (!JFolder::exists($path)) {
         JFolder::create($path);
     }
     $files = JFolder::files($path, $filter, true, true);
     $this->_list = array();
     $optgroup = $root;
     if (is_array($files)) {
         foreach ($files as $file) {
             if (($f = basename(dirname($file))) !== $optgroup) {
                 if ($this->_state->optroup) {
                     $this->_list[] = JHTML::_('select.optgroup', $f);
                 }
             }
             $filepath = str_replace($root . '/', '', $f . '/');
             $filename = basename($file);
             $this->_list[$filename] = JHTML::_('select.option', $filepath . $filename, $filename);
             $this->_images[$filename] = $uripath . '/' . $filepath . $filename;
             if ($f !== $optgroup) {
                 $optgroup = $f;
             }
         }
     }
     ksort($this->_images);
     ksort($this->_list);
     //}
     return $this->_list;
 }
示例#9
0
 /**
  * Image names helper
  * .
  * @param array() | KConfig $config
  * 
  * $config options
  * name         string      column name of helper
  * directory    string      image directory (relative to docroot)
  * filetypes    array       allowd file type extensions
  * deselect     boolean     show -select- option with 0 value
  * preview      boolean     show preview directly below listbox
  * selected     string      currently selected value
  * attribs      array       associative array of listbox attributes
  * 
  * see image_preview for image_preview options 
  */
 public function banner_names($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => 'image_name', 'directory' => JPATH_IMAGES . '/banners', 'filetypes' => array('swf', 'gif', 'jpg', 'png'), 'deselect' => true, 'preview' => true, 'width' => '', 'height' => ''))->append(array('selected' => $config->{$config->name}))->append(array('attribs' => array('id' => $config->name, 'class' => 'inputbox')));
     $root = KRequest::root() . str_replace(JPATH_ROOT, '', $config->directory);
     $default = KRequest::root() . '/media/system/images/blank.png';
     $name = $config->name;
     if (in_array('swf', $config->filetypes->toArray())) {
         JFactory::getDocument()->addScriptDeclaration("\n            window.addEvent('domready', function(){\n                var select = \$('{$name}'), image = \$('{$name}-preview'), flash = \$('{$name}-flash'), x = \$('{$name}-width'), y = \$('{$name}-height'),\n                    loadFlash = function() {\n                        new Swiff('{$root}/' + select.value, {\n                            id: flash.get('id')+'-movie',\n                            container: flash.get('id'),\n                            width: x.value || 150,\n                            height: y.value || 150\n                        });\n                        flash.setStyle('display', 'block');\n                        image.setStyle('display', 'none');\n                    },\n                    loadImage = function() {\n                        image.src = select.value ? ('{$root}/' + select.value) : '{$default}';\n                        image.setStyles({display: 'block', height: y.value.toInt(), width: x.value.toInt()});\n                        flash.setStyle('display', 'none');\n                    };\n            \n                \$\$(select, x, y).addEvent('change', function(){\n                    select.value.test('^(.+).swf\$') ? loadFlash() : loadImage();\n                });\n                \$('{$name}-update').addEvent('click', function(event){event.preventDefault()});\n            });\n            ");
     } else {
         JFactory::getDocument()->addScriptDeclaration("\n            window.addEvent('domready', function(){\n                \$('" . $config->name . "').addEvent('change', function(){\n                    var value = this.value ? ('" . $root . "/' + this.value) : '" . KRequest::root() . "/media/system/images/blank.png';\n                    \$('" . $config->name . "-preview').src = value;\n                });\n            });\n            ");
     }
     if ($config->deselect) {
         $options[] = $this->option(array('text' => '- ' . JText::_('Select') . ' -', 'value' => ''));
     }
     $files = array();
     foreach (new DirectoryIterator($config->directory) as $file) {
         if (in_array(pathinfo($file, PATHINFO_EXTENSION), $config->filetypes->toArray())) {
             $files[] = (string) $file;
         }
     }
     sort($files);
     foreach ($files as $file) {
         $options[] = $this->option(array('text' => (string) $file, 'value' => (string) $file));
     }
     $list = $this->optionlist(array('options' => $options, 'name' => $config->name, 'attribs' => $config->attribs, 'selected' => $config->selected));
     if (in_array('swf', $config->filetypes->toArray())) {
         $list .= ' <span>Banner size:</span> <label for="' . $config->name . '-width">' . JText::_('Width') . '</label>
                     <input class="inputbox" type="text" name="width" 
                         id="' . $config->name . '-width" size="6"  
                         value="' . $config->width . '" /> ' . '<label for="' . $config->name . '-height">' . JText::_('Height') . '</label>
                     <input class="inputbox" type="text" name="height" 
                         id="' . $config->name . '-height" size="6"  
                         value="' . $config->height . '" />' . "<button id=\"" . $config->name . "-update\">" . JText::_('update preview') . "</button>";
     }
     return $config->preview ? $list . '<br />' . $this->image_preview($config) : $list;
 }
示例#10
0
 /**
  * Get the view object attached to the controller.
  *
  * @return LibBaseViewAbstract
  */
 public function getView()
 {
     if (!$this->_view instanceof LibBaseViewAbstract) {
         //Make sure we have a view identifier
         if (!$this->_view instanceof KServiceIdentifier) {
             $this->setView($this->_view);
         }
         //Create the view
         $config = array('media_url' => KRequest::root() . '/media', 'base_url' => KRequest::url()->getUrl(KHttpUrl::BASE), 'state' => $this->getState());
         if ($this->_request->has('layout')) {
             $config['layout'] = $this->_request->get('layout');
         }
         $this->_view = $this->getService($this->_view, $config);
     }
     return $this->_view;
 }
示例#11
0
?>
</h1>
</div>

<div class="row" style="margin-bottom: 20px;">
	<div class="span5">
	<?php 
echo $business->description;
?>
	</div>
	<div class="span4">
		<?php 
if ($business->thumbnail) {
    ?>
		<a rel="shadowbox[gallery]" href="<?php 
    echo KRequest::root() . str_replace(JPATH_ROOT, '', JPATH_IMAGES . '/businesses/' . $business->id . '.jpg');
    ?>
"><img style="border: 1px solid #DDDDDD;" src="<?php 
    echo $business->thumbnail;
    ?>
" ></a>
		<?php 
}
?>
	</div>
</div>

<div class="row">
	<div class="span5">
		<table class="table">
			<?php 
示例#12
0
 public function __get($column)
 {
     if ($column == 'image_path' && !isset($this->_data['image_path'])) {
         return $this->image ? KRequest::root() . '/joomlatools-files/docman-images/' . $this->image : null;
     }
     if ($column == 'icon') {
         if (!is_object($this->params)) {
             $this->params = json_decode($this->params);
         }
         $icon = $this->params->icon ? $this->params->icon : 'icon:default.png';
         return $icon;
     }
     if ($column == 'icon_path') {
         $icon = $this->icon;
         if (substr($icon, 0, 5) === 'icon:') {
             $icon = '/joomlatools-files/docman-icons/' . substr($icon, 5);
         } else {
             $icon = '/media/com_docman/images/icons/' . $icon;
         }
         return KRequest::root() . $icon;
     }
     if ($column == 'storage' && !isset($this->_data['storage'])) {
         return $this->getStorageInfo();
     }
     if (in_array($column, array('published', 'pending', 'expired'))) {
         return $this->{'is' . ucfirst($column)}();
     }
     if ($column === 'status') {
         return $this->isPublished() ? 'published' : ($this->isPending() ? 'pending' : 'expired');
     }
     if (in_array($column, array('size', 'mimetype', 'extension')) && $this->getStorageInfo()) {
         return $this->storage->{$column};
     }
     if ($column == 'category') {
         return $this->getService('com://admin/docman.model.categories')->id($this->docman_category_id)->getItem();
     }
     if ($column === 'description_summary') {
         $description = $this->description;
         $position = strpos($description, '<hr id="system-readmore" />');
         if ($position !== false) {
             return substr($description, 0, $position);
         }
         return $description;
     }
     if ($column === 'description_full') {
         return str_replace('<hr id="system-readmore" />', '', $this->description);
     }
     return parent::__get($column);
 }
示例#13
0
    public function thumbnail($config = array())
    {
        $config = new KConfig($config);
        $config->append(array('images_root' => KRequest::root() . '/joomlatools-files/docman-images/', 'enable_automatic_thumbnail' => true, 'automatic_thumbnail' => false, 'automatic_thumbnail_text' => $this->translate('Automatically generate')));
        //Don't cache automatic thumbnails
        if (!$config->automatic_thumbnail) {
            $config->automatic_thumbnail_image = false;
        }
        $value = $config->value;
        if (!$value) {
            $value = 'default.png';
        }
        if (substr($value, 0, 6) === 'image:') {
            $value = substr($value, 6);
        }
        if ($config->enable_automatic_thumbnail) {
            $html = '<div class="image-picker thumbnail-picker" style="margin-top: 5px">
                        <img
                                id="image-preview"
                                data-src="' . $value . '"
                                src="' . $config->images_root . $value . '"
                                onerror="this.src=\'media://com_docman/images/nothumbnail.png\';"
                                style="max-height:128px;max-width:128px;background:#EEE;margin:0"
                                    />
                        <div id="choose-thumbnail" class="dropdown btn-group" style="float:left;margin-left:5px">
                            <button class="btn choose-photo-button dropdown-toggle" id="profile_header_upload" type="button" data-toggle="dropdown"
                                    style="float:none">
                                    ' . $this->translate('Change thumbnail') . '
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                                <li id="automatic_thumbnail" class="dropdown-link">
                                    <a href="#" class="dropdown-link" id="automatic_thumbnail">
                                        <input style="display:none" type="checkbox" name="automatic_thumbnail" value="1"
                                        ' . ($config->automatic_thumbnail ? 'checked="checked"' : '') . '
                                            />
                                        ' . $this->translate('Automatically generate') . '
                                    </a>
                                </li>
                                <li id="thumbnail-choose-existing" class="dropdown-link">
                                    <div id="image-selector" class="image-selector">
                                        ' . $this->getTemplate()->renderHelper('modal.image', $config->toArray()) . '
                                    </div>
                                </li>
                                <li class="divider"></li>
                                <li id="thumbnail-delete-image" class="pretty-link dropdown-link ">
                                    <a href="#" class="dropdown-link btn" id="image-selector-clear">' . $this->translate('Clear') . '</a>
                                </li>
                            </ul>
                            <p class="help-inline automatic-enabled">' . $this->translate('Thumbnail is automatically generated.') . '</p>
                            <p class="help-inline automatic-unsupported-format">' . $this->translate('Automatically generated thumbnails are only supported on image files.') . '</p>
                            <p class="help-inline automatic-unsupported-location">' . $this->translate('Automatically generated thumbnails are only supported on local files') . '</p>
                        </div>

                    </div>';
        } else {
            $html = '<div class="image-picker thumbnail-picker" style="margin-top: 5px">
                        <img
                                id="image-preview"
                                data-src="' . $value . '"
                                src="' . $config->images_root . $value . '"
                                onerror="this.src=\'media://com_docman/images/nothumbnail.png\';"
                                style="max-height:128px;max-width:128px;background:#EEE;margin:0"
                                    />
                        <div id="choose-thumbnail" class="dropdown btn-group" style="float:left;margin-left:5px">
                            <button class="btn choose-photo-button dropdown-toggle" id="profile_header_upload" type="button" data-toggle="dropdown"
                                    style="float:none">
                                    ' . $this->translate('Change thumbnail') . '
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                                <li id="thumbnail-choose-existing" class="dropdown-link">
                                    <div id="image-selector" class="image-selector">
                                        ' . $this->getTemplate()->renderHelper('modal.image', $config->toArray()) . '
                                    </div>
                                </li>
                                <li class="divider"></li>
                                <li id="thumbnail-delete-image" class="pretty-link dropdown-link ">
                                    <a href="#" class="dropdown-link btn" id="image-selector-clear">' . $this->translate('Clear') . '</a>
                                </li>
                            </ul>
                        </div>

                    </div>';
        }
        return $html;
    }
示例#14
0
<?php

defined('KOOWA') or die('Restricted access');
?>

<script type="text/javascript">
	jQuery(function($){
		<?php 
/* @route('view=post&tmpl=&format=json') fails on sites with SEF + URL suffixes turned on */
?>
		var posts = $('.<?php 
echo @id();
?>
'), url = '<?php 
echo KRequest::root();
?>
/?option=com_ninjaboard&view=post&tmpl=&format=json', parts = [];
		posts.click(function(event){
			if($(event.target).hasClass('delete') && confirm(<?php 
echo json_encode(@text("Are you sure you want to delete this post? This action cannot be undone."));
?>
)){
				parts = event.currentTarget.id.split('-');
				$(event.target).addClass('spinning');
				
				event.preventDefault();
				
				$.post(
					url+'&id='+parts.pop(), 
					{
						action: "delete",
示例#15
0
 protected function _actionUpload()
 {
     if (!($destination = $this->getUploadDestination())) {
         return;
     }
     jimport('joomla.filesystem.file');
     $result = array();
     $result['time'] = date('r');
     $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6);
     $result['agent'] = $_SERVER['HTTP_USER_AGENT'];
     if (count($_GET)) {
         $result['get'] = $_GET;
     }
     if (count($_POST)) {
         $result['post'] = $_POST;
     }
     if (count($_FILES)) {
         $result['files'] = $_FILES;
     }
     // Validation
     $error = false;
     if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
         $error = 'Invalid Upload';
     }
     // Processing
     /**
      * Its a demo, you would move or process the file like:
      *
      * move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/' . $_FILES['Filedata']['name']);
      * $return['src'] = '/uploads/' . $_FILES['Filedata']['name'];
      *
      */
     $upload = $destination . $_FILES['Filedata']['name'];
     $uploaddir = dirname(JPATH_ROOT . $destination . $_FILES['Filedata']['name']);
     JFile::upload($_FILES['Filedata']['tmp_name'], $uploaddir . '/avatar.png');
     KRequest::set('files.uploaded', dirname($upload) . '/avatar.png', 'string');
     if ($error) {
         $return = array('status' => '0', 'error' => $error);
     } else {
         $return = array('status' => '1', 'name' => $_FILES['Filedata']['name'], 'tmp_name' => $_FILES['Filedata']['tmp_name'], 'destination' => $destination, 'uploaded' => KRequest::root() . KRequest::get('files.uploaded', 'string'), 'test' => JPATH_ROOT . KRequest::get('files.uploaded', 'string'));
         // Our processing, we get a hash value from the file
         $return['hash'] = @md5_file(realpath(JPATH_ROOT . $destination . $_FILES['Filedata']['name']));
         // ... and if available, we get image data
         $info = @getimagesize(JPATH_ROOT . KRequest::get('files.uploaded', 'string'));
         if ($info) {
             $return['width'] = $info[0];
             $return['height'] = $info[1];
             $return['mime'] = $info['mime'];
         }
     }
     // Output
     /**
      * Again, a demo case. We can switch here, for different showcases
      * between different formats. You can also return plain data, like an URL
      * or whatever you want.
      *
      * The Content-type headers are uncommented, since Flash doesn't care for them
      * anyway. This way also the IFrame-based uploader sees the content.
      */
     if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') {
         // header('Content-type: text/xml');
         // Really dirty, use DOM and CDATA section!
         echo '<response>';
         foreach ($return as $key => $value) {
             echo "<{$key}><![CDATA[{$value}]]></{$key}>";
         }
         echo '</response>';
     } else {
         // header('Content-type: application/json');
         echo json_encode($return);
     }
     //KFactory::get('lib.joomla.application')->close();
 }
示例#16
0
 public function onAfterRender()
 {
     //If com_ninja don't exist, abort execution to prevent errors
     if (!is_dir(JPATH_ADMINISTRATOR . '/components/com_ninja')) {
         return;
     }
     //If the diagnose failed, FFS don't do anything!
     if (!$this->_diagnose()) {
         return;
     }
     $config = KFactory::get('lib.joomla.config');
     $debug = $config->getValue('config.debug');
     $document = JFactory::getDocument();
     $framework = KFactory::get('admin::com.ninja.helper.default')->framework();
     if ($framework == 'mootools12') {
         if (JVersion::isCompatible('1.6.0')) {
             $core = KRequest::root() . '/media/system/js/mootools-core.js';
             $more = KRequest::root() . '/media/system/js/mootools-more.js';
             //Dramatic workaround code here, should be optimized
             $search[] = '  <script type="text/javascript" src="' . $core . '"></script>' . "\n";
             $search[] = '  <script type="text/javascript" src="' . $more . '"></script>' . "\n";
             $body = str_replace($search, false, JResponse::getBody());
             JResponse::setBody($body);
         } else {
             $script = $debug ? '-uncompressed.js' : '.js';
             unset($document->_scripts[KRequest::root() . '/media/system/js/mootools' . $script]);
         }
         return;
     }
 }
示例#17
0
 /**
  * Renders the output
  * 
  * @param KCommandContext $context Command chain context
  * 
  * @return boolean
  */
 protected function _actionRender(KCommandContext $context)
 {
     //old school of rendering for the backend for now
     $component = $this->getComponent()->getIdentifier()->package;
     $template = $this->_application->getTemplate();
     $file = $this->_request->get('tmpl', 'index');
     if ($component == 'login') {
         $file = 'login';
     }
     $config = array('template' => $template, 'file' => $file . '.php', 'directory' => JPATH_THEMES);
     $document =& JFactory::getDocument();
     $document->addScript(JURI::root(true) . '/administrator/includes/joomla.javascript.js');
     $document->setTitle(htmlspecialchars_decode($this->_application->getCfg('sitename')) . ' - ' . JText::_('Administration'));
     $document->setDescription($this->_application->getCfg('MetaDesc'));
     $document->setBuffer($context->response->getContent(), 'component');
     $content = $document->render(false, $config);
     //lets do some parsing. mission template and legacy stuff
     $content = preg_replace_callback('#(src|href)="templates\\/#', function ($matches) {
         return $matches[1] . '="' . KRequest::base() . '/templates/';
     }, $content);
     $content = preg_replace_callback('#(src|href)="/(media|administrator)/#', function ($matches) {
         return $matches[1] . '="' . KRequest::root() . '/' . $matches[2] . '/';
     }, $content);
     $content = preg_replace_callback('#action="index.php"#', function ($matches) {
         return 'action="index.php?"';
     }, $content);
     $context->response->setContent($content);
 }
示例#18
0
<?php

/* 
 * @version		1.0.0
 * @package		mod_nbtree
 * @author 		Stephanie Scmidt
 * @author mail	admin@dwtutorials.com
 * @link		http://www.dwtutorials.com
 * @copyright	Copyright (C) 2009 Stephanie Scmidt - All rights reserved.
*/
defined('_JEXEC') or die('Restricted access');
// Check if Koowa is active
if (!defined('KOOWA')) {
    JError::raiseWarning(0, JText::_("Koowa wasn't found. Please install the Koowa plugin and enable it."));
    return;
}
KTemplate::loadHelper('script', KRequest::root() . '/media/com_ninja/js/jquery/jquery.pack.js');
JHTML::stylesheet('dtree.css', 'modules/mod_nbtree/css/');
JHTML::script('dtree.js', 'modules/mod_nbtree/js/');
KFactory::get('admin::mod.nbtree.html', array('params' => $params, 'module' => $module, 'attribs' => $attribs))->display();
示例#19
0
 protected function _getAsset($asset, $url, $extension = null)
 {
     if (!$extension) {
         $extension = KRequest::get('get.option', 'cmd');
     }
     $template = KFactory::get('lib.joomla.application')->getTemplate();
     $isMorph = $template == 'morph';
     $custom = '/images/' . $extension . $url;
     $framework = '/media/plg_koowa/' . $asset . $url;
     $fallback = '/media/com_ninja/' . $asset . $url;
     $default = '/media/' . $extension . '/' . $asset . $url;
     $overriden = '/templates/' . $template . '/' . $asset . '/' . $extension . $url;
     if ($isMorph) {
         $overriden = '/templates/' . $template . '/core/' . $asset . '/' . $extension . $url;
         if (class_exists('Morph')) {
             $themelet = '/morph_assets/themelets/' . Morph::getInstance()->themelet . '/' . $asset . '/' . $extension . $url;
         } else {
             $themelet = null;
         }
     }
     //Maybe support more types of assets for $custom in the future
     if ($asset == 'images' && file_exists(JPATH_ROOT . $custom)) {
         return KRequest::root() . $custom;
     } elseif ($isMorph && file_exists(JPATH_ROOT . $themelet)) {
         return KRequest::root() . $themelet;
     } elseif (file_exists(JPATH_BASE . $overriden)) {
         return KRequest::base() . $overriden;
     } elseif (file_exists(JPATH_ROOT . $default)) {
         return KRequest::root() . $default;
     } elseif (file_exists(JPATH_ROOT . $fallback)) {
         return KRequest::root() . $fallback;
     } elseif (file_exists(JPATH_ROOT . $framework)) {
         return KRequest::root() . $framework;
     }
     return false;
 }
示例#20
0
	/**
	* Class constructor.
	*
	* @param	integer	A client identifier.
	*/
    function __construct($config = array())
	{
		jimport('joomla.utilities.utility');

		//set the view name
		$this->_name		= $this->getName();
		$this->_clientId	= $config['clientId'];

		//Enable sessions by default
		if(!isset($config['session'])) {
			$config['session'] = true;
		}

		//Set the session default name
		if(!isset($config['session_name'])) {
			 $config['session_name'] = $this->_name;
		}

		//Set the default configuration file
		if(!isset($config['config_file'])) {
			$config['config_file'] = 'configuration.php';
		}

		//Setup the request
        KRequest::root(str_replace('/'.$this->getName(), '', KRequest::base()));

		//create the configuration object
		$this->_loadConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']);

		//set defines
		define('JPATH_CACHE', $this->getCfg('cache_path', JPATH_ROOT.'/cache'));

		//Set the session autostart
		if(!isset($config['session_autostart'])) {
			 $config['session_autostart'] = !is_null($this->getCfg('session_autostart')) ? $this->getCfg('session_autostart') :  true;
		}

		//create the session if a session name is passed
		if($config['session'] !== false) {
			$this->_loadSession(JUtility::getHash($config['session_name']), false, $config['session_autostart']);
		}

		//create the site
		if(isset($config['multisite']) && $config['multisite'] == true)
		{
	        //Set the session default name
		    if(!isset($config['site'])) {
			    $config['site'] = 'default';
		    }

		    $this->_loadSite($config['site']);
		}

		$this->set( 'requestTime', gmdate('Y-m-d H:i') );
	}
 public function __construct($subject, $config = array())
 {
     // Turn off E_STRICT errors for now
     error_reporting(error_reporting() & ~E_STRICT);
     // Command line fixes for Joomla
     if (PHP_SAPI === 'cli') {
         if (!isset($_SERVER['HTTP_HOST'])) {
             $_SERVER['HTTP_HOST'] = '';
         }
         if (!isset($_SERVER['REQUEST_METHOD'])) {
             $_SERVER['REQUEST_METHOD'] = '';
         }
     }
     // Check if Koowa is active
     if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
         JError::raiseWarning(0, JText::_("Koowa plugin requires MySQLi Database Driver. Please change your database configuration settings to 'mysqli'"));
         return;
     }
     // Check for suhosin
     if (in_array('suhosin', get_loaded_extensions())) {
         //Attempt setting the whitelist value
         @ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://');
         //Checking if the whitelist is ok
         if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) {
             JError::raiseWarning(0, sprintf(JText::_('Your server has Suhosin loaded. Please follow <a href="%s" target="_blank">this</a> tutorial.'), 'http://www.joomlatools.com/framework-known-issues'));
             return;
         }
     }
     //Safety Extender compatibility
     if (extension_loaded('safeex') && strpos('tmpl', @ini_get('safeex.url_include_proto_whitelist')) === false) {
         $whitelist = @ini_get('safeex.url_include_proto_whitelist');
         $whitelist = (strlen($whitelist) ? $whitelist . ',' : '') . 'tmpl';
         @ini_set('safeex.url_include_proto_whitelist', $whitelist);
     }
     // Set pcre.backtrack_limit to a larger value
     // See: https://bugs.php.net/bug.php?id=40846
     if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
         @ini_set('pcre.backtrack_limit', 1000000);
     }
     //Set constants
     define('KDEBUG', JDEBUG);
     //Set path definitions
     define('JPATH_FILES', JPATH_ROOT);
     define('JPATH_IMAGES', JPATH_ROOT . DS . 'images');
     //Set exception handler
     set_exception_handler(array($this, 'exceptionHandler'));
     // Koowa : setup
     require_once JPATH_LIBRARIES . '/koowa/koowa.php';
     Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
     KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
     KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
     KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
     KServiceIdentifier::setApplication('site', JPATH_SITE);
     KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
     KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
     KService::setAlias('translator', 'com:default.translator');
     //Setup the request
     KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
     //Load the koowa plugins
     JPluginHelper::importPlugin('koowa', null, true, KService::get('com://admin/default.event.dispatcher'));
     //Bugfix : Set offset accoording to user's timezone
     if (!JFactory::getUser()->guest) {
         if ($offset = JFactory::getUser()->getParam('timezone')) {
             JFactory::getConfig()->setValue('config.offset', $offset);
         }
     }
     // Load language files for the framework
     KService::get('com:default.translator')->loadLanguageFiles();
     parent::__construct($subject, $config);
 }
示例#22
0
 /**
  * Get the view object attached to the controller
  *
  * This function will check if the view folder exists. If not it will throw
  * an exception. This is a security measure to make sure we can only explicitly
  * get data from views the have been physically defined.
  *
  * @throws  KControllerException if the view cannot be found.
  * @return	KViewAbstract
  *
  */
 public function getView()
 {
     if (!$this->_view instanceof KViewAbstract) {
         //Make sure we have a view identifier
         if (!$this->_view instanceof KServiceIdentifier) {
             $this->setView($this->_view);
         }
         //Create the view
         $config = array('model' => $this->getModel(), 'media_url' => KRequest::root() . '/media', 'base_url' => KRequest::url()->get(KHttpUrl::BASE));
         if ($this->isExecutable()) {
             $config['auto_assign'] = !$this->getBehavior('executable')->isReadOnly();
         }
         $this->_view = $this->getService($this->_view, $config);
         //Set the layout
         if (isset($this->_request->layout)) {
             $this->_view->setLayout($this->_request->layout);
         }
         //Make sure the view exists
         if (!file_exists(dirname($this->_view->getIdentifier()->filepath))) {
             throw new KControllerException('View : ' . $this->_view->getName() . ' not found', KHttpResponse::NOT_FOUND);
         }
     }
     return $this->_view;
 }
示例#23
0
    /**
     * function description
     *
     * @author 		Stian Didriksen <*****@*****.**>
     * @return 		returns an image nested in an anchor element.
     */
    public function required($enable, $id, $imgY = 'enable.png', $imgX = 'disable.png')
    {
        //Load koowa javascript
        KTemplateAbstract::loadHelper('script', KRequest::root() . '/media/plg_koowa/js/koowa.js');
        $img = $enable ? $imgY : $imgX;
        $alt = $enable ? JText::_('Required') : JText::_('Optional');
        $text = $enable ? JText::_('Make item optional') : JText::_('Require Item');
        $action = $enable ? 'optional' : 'required';
        $href = '
		<a href="#" onclick="Koowa.Form.addField(\'' . $action . '\', \'cb' . $id . '\');Koowa.Form.addField(\'action\', \'' . $action . '\');Koowa.Form.submit(\'post\')" title="' . $text . '">
		<img src="' . JURI::root() . 'media/com_ninja/images/16/' . $img . '" border="0" alt="' . $alt . '" />
		</a>';
        return $href;
    }
示例#24
0
 protected function _replaceInlineCSSMatch($matches)
 {
     $match = trim($matches[1], '"\'');
     if (strpos($match, '..') === 0) {
         $match = KRequest::root() . ltrim($match, '.');
     }
     return str_replace($matches[1], $this->_processResourceURL($match), $matches[0]);
 }
示例#25
0
 /**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional KConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     //Clone the identifier
     $identifier = clone $this->_identifier;
     
     $config->append(array(
         'data'			   => array(),
         'escape'           => 'htmlspecialchars',
         'template'         => $this->getName(),
         'template_filters' => array('shorttag', 'alias', 'variable', 'script', 'style', 'link', 'template'),
         'auto_assign'      => true,
         'base_url'         => KRequest::base(),
         'media_url'        => KRequest::root().'/media',
     ));
     
     parent::_initialize($config);
 }
示例#26
0
 /**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional KConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('escape' => 'htmlspecialchars', 'layout_default' => 'default', 'template' => null, 'template_filters' => array('shorttag', 'alias', 'variable', 'script', 'style', 'link'), 'template_path' => null, 'auto_assign' => true, 'auto_filter' => false, 'base_url' => KRequest::base(), 'media_url' => KRequest::root() . '/media'))->append(array('layout' => $config->layout_default));
     parent::_initialize($config);
 }
示例#27
0
 /**
  * Loads the application.
  */
 protected function _actionLoad($context)
 {
     //already loaded
     if ($this->_application instanceof JApplication) {
         return;
     }
     //legacy register error handling
     JError::setErrorHandling(E_ERROR, 'callback', array($this, 'exception'));
     //register exception handler
     set_exception_handler(array($this, 'exception'));
     $identifier = clone $this->getIdentifier();
     $identifier->name = 'application';
     //load the JSite
     $this->getService('koowa:loader')->loadIdentifier($identifier);
     jimport('joomla.application.component.helper');
     //no need to create session when using CLI (command line interface)
     $this->_application = JFactory::getApplication($this->_application, array('session' => PHP_SAPI !== 'cli'));
     global $mainframe;
     $mainframe = $this->_application;
     $error_reporting = $this->_application->getCfg('error_reporting');
     define('JDEBUG', $this->_application->getCfg('debug'));
     //taken from nooku application dispatcher
     if ($error_reporting > 0) {
         error_reporting($error_reporting);
         ini_set('display_errors', 1);
         ini_set('display_startup_errors', 1);
     }
     $this->getService()->set($identifier, $this->_application);
     $this->getService()->setAlias('application', $identifier);
     //set the session handler to none for
     if (PHP_SAPI == 'cli') {
         JFactory::getConfig()->setValue('config.session_handler', 'none');
         JFactory::getConfig()->setValue('config.cache_handler', 'file');
     }
     //set the default timezone to UTC
     date_default_timezone_set('UTC');
     KRequest::root(str_replace('/' . $this->_application->getName(), '', KRequest::base()));
 }
示例#28
0
文件: html.php 项目: stonyyi/anahita
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional KConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('media_url' => KRequest::root() . '/media', 'template_filters' => array('chrome'), 'data' => array('styles' => array())));
     parent::_initialize($config);
 }
示例#29
0
 public function __toString()
 {
     if ($result = $this->getText()) {
         if ($this->isTranslatable()) {
             $result = $this->_translator->translate($result);
         }
         $result = '<span class="content">' . $result . '</span>';
         if (($link = $this->_link) && ($url = $link->url)) {
             $attribs = $link->attribs ? KHelperArray::toString(KConfig::unbox($link->attribs)) : '';
             if (strpos($url, 'mailto:') !== 0) {
                 if ($link->route) {
                     $url = JRoute::_($url);
                     if (version_compare(JVERSION, '1.6', '<') && JFactory::getApplication()->isAdmin()) {
                         // TODO Remove when J!1.5 support is dropped. J!1.5 backend router does not append the
                         // path relative to document root.
                         $url = KRequest::base() . '/' . $url;
                     }
                 } else {
                     // If routing is disabled, URLs are assumed as relative to site root.
                     $url = KRequest::root() . '/' . $url;
                 }
                 if ($link->absolute) {
                     $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $url;
                 }
             }
             if (!$link->route) {
                 $url = htmlspecialchars($url, ENT_QUOTES);
                 // Routed links are already escaped.
             }
             $result = '<a ' . $attribs . ' href="' . $url . '">' . $result . '</a>';
         }
         if ($attribs = $this->_attribs) {
             // TODO It seems that KHelperArray::toString is not properly working. Need to do the following
             // for having properly rendered attribs.
             foreach ($attribs as $attrib => $value) {
                 if (is_object($value)) {
                     $attribs->{$attrib} = implode(' ', KConfig::unbox($value));
                 }
             }
             $result = '<span ' . KHelperArray::toString($attribs) . '>' . $result . '</span>';
         }
     } else {
         $result = $this->getName(true);
     }
     return $result;
 }