示例#1
0
 /**
  * Check login status of current user with regards to google
  *
  * @return  array  $status
  */
 public function status()
 {
     // Essentually, in the background, we're just going to try and make a request to check if the user is logged in
     // If they are, we'll add their email address to the google login button, thus offering the sign out option as well
     // @FIXME: logout below is a total hack!
     $js = "(function() {\n\t\t\t\t\tvar po   = document.createElement('script');\n\t\t\t\t\tpo.type  = 'text/javascript';\n\t\t\t\t\tpo.async = true;\n\t\t\t\t\tpo.src   = 'https://apis.google.com/js/client:plusone.js?onload=OnLoadCallback';\n\t\t\t\t\tvar s    = document.getElementsByTagName('script')[0];\n\t\t\t\t\ts.parentNode.insertBefore(po, s);\n\n\t\t\t\t\tOnLoadCallback = function () {\n\t\t\t\t\t\tgapi.auth.authorize({\n\t\t\t\t\t\t\tclient_id     : '{$this->params->get('app_id')}',\n\t\t\t\t\t\t\timmediate     : true,\n\t\t\t\t\t\t\tresponse_type : 'token',\n\t\t\t\t\t\t\tscope         : 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'\n\t\t\t\t\t\t}, function ( response ) {\n\t\t\t\t\t\t\tif (response && !response.error) {\n\t\t\t\t\t\t\t\tgapi.client.load('oauth2', 'v2', function () {\n\t\t\t\t\t\t\t\t\tvar request = gapi.client.oauth2.userinfo.get({\n\t\t\t\t\t\t\t\t\t\t'userId' : 'me'\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\trequest.execute(function ( resp ) {\n\t\t\t\t\t\t\t\t\t\tvar google = \$('#google').siblings('.sign-out');\n\t\t\t\t\t\t\t\t\t\tgoogle.find('.current-user').html(resp.email);\n\n\t\t\t\t\t\t\t\t\t\tgoogle.on('click', function ( e ) {\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\$('body').append('<iframe src=\"https://accounts.google.com/logout\" style=\"display:none;\">');\n\t\t\t\t\t\t\t\t\t\t\tgoogle.animate({'margin-top': -42}, function() {\n\t\t\t\t\t\t\t\t\t\t\t\tgoogle.find('.current-user').html('');\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t})();";
     Document::addScriptDeclaration($js);
 }
示例#2
0
 /**
  * Check login status of current user with regards to facebook
  *
  * @return  array  $status
  */
 public function status()
 {
     // Get the hub url
     $service = trim(Request::base(), '/');
     $channelUrl = $service . '/channel.phtml';
     // This can only currently be done using the Facebook JS API
     // (at least relying solely on the native methods provided by the language's specific API)
     $js = "\$(document).ready(function () {\n\t\t\t\$('body').append('<div id=\"fb-root\"></div>');\n\t\t\t\$.ajaxSetup({ cache: true });\n\t\t\t\$.getScript('//connect.facebook.net/en_US/all.js', function () {\n\t\t\t\twindow.fbAsyncInit = function () {\n\t\t\t\t\tFB.init({\n\t\t\t\t\t\tappId: '{$this->params->get('app_id')}',\n\t\t\t\t\t\tchannelUrl: '{$channelUrl}'\n\t\t\t\t\t});\n\n\t\t\t\t\tFB.getLoginStatus(function ( response ) {\n\t\t\t\t\t\tif (response.status === 'connected') {\n\t\t\t\t\t\t\tFB.api('/me', function ( response ) {\n\t\t\t\t\t\t\t\tvar facebook = \$('#facebook').siblings('.sign-out');\n\t\t\t\t\t\t\t\tfacebook.find('.current-user').html(response.name);\n\n\t\t\t\t\t\t\t\tfacebook.on('click', function( e ) {\n\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\tFB.logout(function() {\n\t\t\t\t\t\t\t\t\t\tfacebook.animate({'margin-top': -42}, function() {\n\t\t\t\t\t\t\t\t\t\t\tfacebook.find('.current-user').html('');\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t});\n\t\t});";
     Document::addScriptDeclaration($js);
 }
示例#3
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Load the javascript
     Html::behavior('framework');
     Html::behavior('modal', 'input.modal');
     // Build the script.
     $script = array();
     $script[] = '	function jSelectChart_' . $this->id . '(id, name, object) {';
     $script[] = '		$("#' . $this->id . '_id").val(id);';
     $script[] = '		$("#' . $this->id . '_name").val(name);';
     $script[] = '		$.fancybox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     Document::addScriptDeclaration(implode("\n", $script));
     // Build the script.
     $script = array();
     $script[] = '	jQuery(document).ready(function($){';
     $script[] = '		var div = $("<div>").css("display", "none").prependTo($("#menu-types"));';
     $script[] = '		$("#menu-types").append(div);';
     $script[] = '	});';
     // Add the script to the document head.
     Document::addScriptDeclaration(implode("\n", $script));
     // Get the title of the linked chart
     $db = App::get('db');
     $db->setQuery('SELECT name' . ' FROM #__newsfeeds' . ' WHERE id = ' . (int) $this->value);
     $title = $db->loadResult();
     if ($error = $db->getErrorMsg()) {
         throw new Exception($error, 500);
     }
     if (empty($title)) {
         $title = Lang::txt('COM_NEWSFEEDS_SELECT_A_FEED');
     }
     $link = 'index.php?option=com_newsfeeds&amp;view=newsfeeds&amp;layout=modal&amp;tmpl=component&amp;function=jSelectChart_' . $this->id;
     Html::behavior('modal', 'a.modal');
     $html = "\n" . '<div class="fltlft"><input type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" /></div>';
     $html .= '<div class="button2-left"><div class="blank"><a class="modal" title="' . Lang::txt('COM_NEWSFEEDS_CHANGE_FEED_BUTTON') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . Lang::txt('COM_NEWSFEEDS_CHANGE_FEED_BUTTON') . '</a></div></div>' . "\n";
     // The active newsfeed id field.
     if (0 == (int) $this->value) {
         $value = '';
     } else {
         $value = (int) $this->value;
     }
     // class='required' for client side validation
     $class = '';
     if ($this->required) {
         $class = ' class="required modal-value"';
     }
     $html .= '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
     return $html;
 }
示例#4
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Load the modal behavior script.
     Html::behavior('modal', 'a.modal');
     // Build the script.
     $script = array();
     $script[] = '	function jSelectArticle_' . $this->id . '(id, title, catid, object) {';
     $script[] = '		$("#' . $this->id . '_id").val(id);';
     $script[] = '		$("#' . $this->id . '_name").val(title);';
     $script[] = '		$.fancybox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     Document::addScriptDeclaration(implode("\n", $script));
     // Setup variables for display.
     $html = array();
     $link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;function=jSelectArticle_' . $this->id;
     $db = App::get('db');
     $db->setQuery('SELECT title' . ' FROM #__content' . ' WHERE id = ' . (int) $this->value);
     $title = $db->loadResult();
     if ($error = $db->getErrorMsg()) {
         throw new Exception($error, 500);
     }
     if (empty($title)) {
         $title = Lang::txt('COM_CONTENT_SELECT_AN_ARTICLE');
     }
     $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
     // The current user display field.
     $html[] = '<div class="input-modal">';
     $html[] = '  <span class="input-cell">';
     $html[] = '    <input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
     $html[] = '  </span>';
     // The user select button.
     $html[] = '  <span class="input-cell">';
     $html[] = '    <a class="modal button" title="' . Lang::txt('COM_CONTENT_CHANGE_ARTICLE') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . Lang::txt('COM_CONTENT_CHANGE_ARTICLE_BUTTON') . '</a>';
     $html[] = '  </span>';
     $html[] = '</div>';
     // The active article id field.
     if (0 == (int) $this->value) {
         $value = '';
     } else {
         $value = (int) $this->value;
     }
     // class='required' for client side validation
     $class = '';
     if ($this->required) {
         $class = ' class="required modal-value"';
     }
     $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
     return implode("\n", $html);
 }
示例#5
0
 function display($tpl = null)
 {
     // Do not allow cache
     App::get('response')->headers->set('Cache-Control', 'no-cache', false);
     App::get('response')->headers->set('Pragma', 'no-cache');
     \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'popup-imagelist.css');
     Document::addScriptDeclaration("var ImageManager = window.parent.ImageManager;");
     $images = $this->get('images');
     $folders = $this->get('folders');
     $state = $this->get('state');
     $this->baseURL = COM_MEDIA_BASEURL;
     $this->assignRef('images', $images);
     $this->assignRef('folders', $folders);
     $this->assignRef('state', $state);
     parent::display($tpl);
 }
示例#6
0
 /**
  * readmore button
  *
  * @return  array  A two element array of (imageName, textToInsert)
  */
 public function onDisplay($name)
 {
     $template = App::get('template')->template;
     // button is not active in specific content components
     $getContent = $this->_subject->getContent($name);
     $present = Lang::txt('PLG_READMORE_ALREADY_EXISTS', true);
     $js = "\n\t\t\tfunction insertReadmore(editor) {\n\t\t\t\tvar content = {$getContent}\n\t\t\t\tif (content.match(/<hr\\s+id=(\"|')system-readmore(\"|')\\s*\\/*>/i)) {\n\t\t\t\t\talert('{$present}');\n\t\t\t\t\treturn false;\n\t\t\t\t} else {\n\t\t\t\t\tjInsertEditorText('<hr id=\"system-readmore\" />', editor);\n\t\t\t\t}\n\t\t\t}\n\t\t\t";
     Document::addScriptDeclaration($js);
     $button = new \Hubzero\Base\Object();
     $button->set('modal', false);
     $button->set('onclick', 'insertReadmore(\'' . $name . '\');return false;');
     $button->set('text', Lang::txt('PLG_READMORE_BUTTON_READMORE'));
     $button->set('name', 'readmore');
     // TODO: The button writer needs to take into account the javascript directive
     //$button->set('link', 'javascript:void(0)');
     $button->set('link', '#');
     return $button;
 }
示例#7
0
    /**
     * Initialise the captcha
     *
     * @param   string   $id  The id of the field.
     * @return  boolean  True on success, false otherwise
     * @since   2.5
     */
    public function onInit($id)
    {
        // Initialise variables
        $lang = $this->_getLanguage();
        $pubkey = $this->params->get('public_key', '');
        $theme = $this->params->get('theme', 'clean');
        if ($pubkey == null || $pubkey == '') {
            throw new Exception(Lang::txt('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY'));
        }
        $server = self::RECAPTCHA_API_SERVER;
        if (Request::isSecure()) {
            $server = self::RECAPTCHA_API_SECURE_SERVER;
        }
        Html::asset('script', $server . '/js/recaptcha_ajax.js');
        Document::addScriptDeclaration('jQuery(document).ready(function($) {
			Recaptcha.create("' . $pubkey . '", "dynamic_recaptcha_1", {theme: "' . $theme . '",' . $lang . 'tabindex: 0});
		});');
        return true;
    }
示例#8
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $template = App::get('template')->template;
     $fieldName = $control_name . '[' . $name . ']';
     $article = JTable::getInstance('content');
     if ($value) {
         $article->load($value);
     } else {
         $article->title = Lang::txt('COM_CONTENT_SELECT_AN_ARTICLE');
     }
     $js = "\n\t\tfunction jSelectArticle_" . $name . "(id, title, catid, object) {\n\t\t\tdocument.getElementById(object + '_id').value = id;\n\t\t\tdocument.getElementById(object + '_name').value = title;\n\t\t\tSqueezeBox.close();\n\t\t}";
     Document::addScriptDeclaration($js);
     $link = 'index.php?option=com_content&amp;task=element&amp;tmpl=component&amp;function=jSelectArticle_' . $name;
     Html::behavior('modal', 'a.modal');
     $html = "\n" . '<div class="fltlft"><input type="text" id="' . $name . '_name" value="' . htmlspecialchars($article->title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" /></div>';
     //$html .= "\n &#160; <input class=\"inputbox modal-button\" type=\"button\" value=\"".Lang::txt('JSELECT')."\" />";
     $html .= '<div class="button2-left"><div class="blank"><a class="modal" title="' . Lang::txt('COM_CONTENT_SELECT_AN_ARTICLE') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 650, y: 375}}">' . Lang::txt('JSELECT') . '</a></div></div>' . "\n";
     $html .= "\n" . '<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />';
     return $html;
 }
示例#9
0
 /**
  * Display the button
  *
  * @return array A four element array of (article_id, article_title, category_id, object)
  */
 public function onDisplay($name)
 {
     // Javascript to insert the link
     // View element calls jSelectArticle when an article is clicked
     // jSelectArticle creates the link tag, sends it to the editor,
     // and closes the select frame.
     $js = "\n\t\tfunction jSelectArticle(id, title, catid, object, link, lang) {\n\t\t\tvar hreflang = '';\n\t\t\tif (lang !== '') {\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\n\t\t\t}\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\t\$.fancybox.close();\n\t\t}";
     Document::addScriptDeclaration($js);
     Html::behavior('modal');
     // Use the built-in element view to select the article.
     // Currently uses blank class.
     $link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . Session::getFormToken() . '=1';
     $button = new \Hubzero\Base\Object();
     $button->set('modal', true);
     $button->set('link', $link);
     $button->set('text', Lang::txt('PLG_ARTICLE_BUTTON_ARTICLE'));
     $button->set('name', 'article');
     $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}");
     return $button;
 }
示例#10
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Get the client id.
     $clientId = $this->element['client_id'];
     if (!isset($clientId)) {
         $clientName = $this->element['client'];
         if (isset($clientName)) {
             $client = JApplicationHelper::getClientInfo($clientName, true);
             $clientId = $client->id;
         }
     }
     if (!isset($clientId) && $this->form instanceof JForm) {
         $clientId = $this->form->getValue('client_id');
     }
     $clientId = (int) $clientId;
     // Load the modal behavior script.
     Html::behavior('modal', 'a.modal');
     // Build the script.
     $script = array();
     $script[] = '	function jSelectPosition_' . $this->id . '(name) {';
     $script[] = '		$("#' . $this->id . '").val(name);';
     $script[] = '		$.fancybox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     Document::addScriptDeclaration(implode("\n", $script));
     // Setup variables for display.
     $html = array();
     $link = 'index.php?option=com_modules&amp;view=positions&amp;layout=modal&amp;tmpl=component&amp;function=jSelectPosition_' . $this->id . '&amp;client_id=' . $clientId;
     // The current user display field.
     //$html[] = '<div class="fltlft">';
     $html[] = '<div class="input-modal">';
     $html[] = '<span class="input-cell">';
     $html[] = parent::getInput();
     $html[] = '</span>';
     // The user select button.
     $html[] = '<span class="input-cell">';
     $html[] = '<a class="button modal" title="' . Lang::txt('COM_MODULES_CHANGE_POSITION_TITLE') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . Lang::txt('COM_MODULES_CHANGE_POSITION_BUTTON') . '</a>';
     $html[] = '</span>';
     $html[] = '</div>';
     return implode("\n", $html);
 }
示例#11
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Initialise variables.
     $html = array();
     $recordId = (int) $this->form->getValue('id');
     $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
     $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
     // Get a reverse lookup of the base link URL to Title
     $model = JModelLegacy::getInstance('menutypes', 'menusModel');
     $rlu = $model->getReverseLookup();
     switch ($this->value) {
         case 'url':
             $value = Lang::txt('COM_MENUS_TYPE_EXTERNAL_URL');
             break;
         case 'alias':
             $value = Lang::txt('COM_MENUS_TYPE_ALIAS');
             break;
         case 'separator':
             $value = Lang::txt('COM_MENUS_TYPE_SEPARATOR');
             break;
         default:
             $link = $this->form->getValue('link');
             // Clean the link back to the option, view and layout
             $value = Lang::txt(\Hubzero\Utility\Arr::getValue($rlu, MenusHelper::getLinkKey($link)));
             break;
     }
     // Load the javascript and css
     Html::behavior('framework');
     Html::behavior('modal');
     Document::addScriptDeclaration("\n\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t\$('input.modal').fancybox({\n\t\t\t\t\tarrows: false,\n\t\t\t\t\ttype: 'iframe',\n\t\t\t\t\tautoSize: false,\n\t\t\t\t\tfitToView: false,\n\t\t\t\t\twidth: 600,\n\t\t\t\t\theight: 450,\n\t\t\t\t\thref: '" . Route::url('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId, false) . "'\n\t\t\t\t});\n\t\t\t});\n\t\t");
     $html[] = '<div class="input-modal">';
     $html[] = '<span class="input-cell">';
     $html[] = '<input type="text" id="' . $this->id . '" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
     $html[] = '</span><span class="input-cell">';
     $html[] = '<input type="button" class="modal" value="' . Lang::txt('JSELECT') . '" />';
     $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     $html[] = '</span>';
     $html[] = '</div>';
     return implode("\n", $html);
 }
示例#12
0
 function display($tpl = null)
 {
     $config = Component::params('com_media');
     $style = Request::getState('media.list.layout', 'layout', 'thumbs', 'word');
     Document::setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu');
     Html::behavior('framework', true);
     \Hubzero\Document\Assets::addComponentScript('com_media', 'mediamanager.js');
     \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'mediamanager.css');
     Html::behavior('modal');
     Document::addScriptDeclaration("\n\t\tjQuery(document).ready(function(\$){\n\t\t\tdocument.preview = \$.fancybox;\n\t\t});");
     Html::asset('script', 'system/jquery.treeview.js', true, true, false, false);
     Html::asset('stylesheet', 'system/jquery.treeview.css', array(), true);
     if (Lang::isRTL()) {
         Html::asset('stylesheet', 'media/jquery.treeview_rtl.css', array(), true);
     }
     if (DIRECTORY_SEPARATOR == '\\') {
         $base = str_replace(DIRECTORY_SEPARATOR, "\\\\", COM_MEDIA_BASE);
     } else {
         $base = COM_MEDIA_BASE;
     }
     $js = "\n\t\t\tvar basepath = '" . $base . "';\n\t\t\tvar viewstyle = '" . $style . "';\n\t\t";
     Document::addScriptDeclaration($js);
     // Display form for FTP credentials?
     // Don't set them here, as there are other functions called before this one if there is any file write operation
     $ftp = !JClientHelper::hasCredentials('ftp');
     $session = App::get('session');
     $state = $this->get('state');
     $this->assignRef('session', $session);
     $this->assignRef('config', $config);
     $this->assignRef('state', $state);
     $this->require_ftp = $ftp;
     $this->folders_id = ' id="media-tree"';
     $this->folders = $this->get('folderTree');
     // Set the toolbar
     $this->addToolbar();
     parent::display($tpl);
     echo Html::behavior('keepalive');
 }
示例#13
0
 function display($tpl = null)
 {
     // Do not allow cache
     App::get('response')->headers->set('Cache-Control', 'no-cache', false);
     App::get('response')->headers->set('Pragma', 'no-cache');
     $style = Request::getState('media.list.layout', 'layout', 'thumbs', 'word');
     Html::behavior('framework', true);
     //Document::addStyleSheet('../media/media/css/medialist-'.$style.'.css');
     \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'medialist-' . $style . '.css');
     if (Lang::isRTL()) {
         //Document::addStyleSheet('../media/media/css/medialist-'.$style.'_rtl.css');
         \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'medialist-' . $style . '_rtl.css');
     }
     Document::addScriptDeclaration("\n\t\tjQuery(document).ready(function(\$){\n\t\t\twindow.parent.document.updateUploader();\n\t\t\t\$('a.img-preview').on('click', function(e) {\n\t\t\t\te.preventDefault();\n\t\t\t\twindow.top.document.preview.open(\$(this).attr('href'));\n\t\t\t});\n\t\t});");
     $images = $this->get('images');
     $documents = $this->get('documents');
     $folders = $this->get('folders');
     $state = $this->get('state');
     // Check for invalid folder name
     if (empty($state->folder)) {
         $dirname = Request::getVar('folder', '', '', 'string');
         if (!empty($dirname)) {
             $dirname = htmlspecialchars($dirname, ENT_COMPAT, 'UTF-8');
             if (Lang::hasKey('COM_MEDIA_ERROR_UNABLE_TO_BROWSE_FOLDER_WARNDIRNAME')) {
                 throw new Exception(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_BROWSE_FOLDER_WARNDIRNAME', $dirname), 100);
             } else {
                 throw new Exception(sprintf('Unable to browse:&#160;%s. Directory name must only contain alphanumeric characters and no spaces.', $dirname), 100);
             }
         }
     }
     $this->baseURL = Request::root();
     $this->assignRef('images', $images);
     $this->assignRef('documents', $documents);
     $this->assignRef('folders', $folders);
     $this->assignRef('state', $state);
     parent::display($tpl);
 }
示例#14
0
 /**
  * Check login status of current user with regards to linkedin
  *
  * @return  array $status
  */
 public function status()
 {
     $js = "\$(document).ready(function() {\n\t\t\t\t\t\$.getScript('https://platform.linkedin.com/in.js?async=true', function success() {\n\t\t\t\t\t\tonLinkedInLoad = function () {\n\t\t\t\t\t\t\tif (IN.User.isAuthorized()) {\n\t\t\t\t\t\t\t\tIN.API.Profile('me').result(function(profile) {\n\t\t\t\t\t\t\t\t\tvar linkedin = \$('#linkedin').siblings('.sign-out');\n\t\t\t\t\t\t\t\t\tlinkedin\n\t\t\t\t\t\t\t\t\t\t.find('.current-user')\n\t\t\t\t\t\t\t\t\t\t.html(profile.values[0].firstName+' '+profile.values[0].lastName);\n\n\t\t\t\t\t\t\t\t\tlinkedin.on('click', function( e ) {\n\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\tIN.User.logout(function() {\n\t\t\t\t\t\t\t\t\t\t\tlinkedin.animate({'margin-top': -42}, function() {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkedin.find('.current-user').html('');\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tIN.init({\n\t\t\t\t\t\t\tapi_key   : '{$this->params->get('api_key')}',\n\t\t\t\t\t\t\tonLoad    : 'onLinkedInLoad',\n\t\t\t\t\t\t\tauthorize : true\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});";
     Document::addScriptDeclaration($js);
 }
示例#15
0
 /**
  * Adds the editor specific insert method.
  *
  * @return boolean
  */
 public function onGetInsertMethod()
 {
     static $done = false;
     // Do this only once.
     if (!$done) {
         $done = true;
         $js = "\tfunction jInsertEditorText(text, editor) {\n\t\t\t\t\tJoomla.editors.instances[editor].replaceSelection(text);\n\n\t\t\t}";
         Document::addScriptDeclaration($js);
     }
     return true;
 }
示例#16
0
 /**
  * Display the form allowing to edit a citation
  *
  * @return  string  HTML
  */
 private function editAction($row = null)
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (!$this->params->get('access-manage')) {
         throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
     }
     // Create view object
     $view = $this->view('edit');
     $view->member = $this->member;
     $view->option = $this->option;
     $view->database = $this->database;
     $view->allow_tags = $this->member->getParam('citation_allow_tags', 'yes');
     $view->allow_badges = $this->member->getParam('citatoin_allow_badges', 'yes');
     // Get the citation types
     $citationsType = \Components\Citations\Models\Type::all();
     $view->types = $citationsType->rows();
     $fields = array();
     foreach ($view->types as $type) {
         if (isset($type->fields)) {
             $f = $type->fields;
             if (strpos($f, ',') !== false) {
                 $f = str_replace(',', "\n", $f);
             }
             $f = array_map('trim', explode("\n", $f));
             $f = array_values(array_filter($f));
             $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f;
         }
     }
     // Incoming
     $id = Request::getInt('cid', 0);
     // Load the object
     if (is_object($row)) {
         $view->row = $row;
     } else {
         $view->row = \Components\Citations\Models\Citation::oneOrNew($id);
         // check to see if this member created this citation
         if (!$view->row->isNew() && ($view->row->uid != User::get('id') || $view->row->scope != 'member')) {
             // redirect
             App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name), Lang::txt('PLG_MEMBERS_CITATIONS_OWNER_ONLY'), 'warning');
         }
     }
     //make sure title isnt too long
     $maxTitleLength = 30;
     $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '&hellip;' : $view->row->title;
     // Set the pathway
     if ($id && $id != 0) {
         Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id);
         Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_EDIT'));
     } else {
         Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_ADD'));
     }
     // Set the page title
     Document::setTitle(Lang::txt('PLG_MEMBERS_CITATIONS_CITATION') . $shortenedTitle);
     //push jquery to doc
     Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';');
     // Instantiate a new view
     $view->title = Lang::txt('PLG_MEMBERS_CITATIONS') . ': ' . Lang::txt('PLG_MEMBERS_CITATIONS_' . strtoupper($this->action));
     // No ID, so we're creating a new entry
     // Set the ID of the creator
     if (!$id) {
         $view->row->uid = User::get('id');
         //tags & badges
         $view->tags = array();
         $view->badges = array();
         $view->row->id = -time();
     } else {
         if ($view->row->relatedAuthors->count()) {
             $view->authors = $view->row->relatedAuthors;
         } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') {
             // formats the author for the multi-author plugin
             $authors = explode(';', $view->row->author);
             $authorString = '';
             $totalAuths = count($authors);
             $x = 0;
             foreach ($authors as &$author) {
                 /***
                  * Because the multi-select keys off of a comma,
                  * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select
                  * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to
                  * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME})
                  ***/
                 $authorEntry = explode(',', $author);
                 if (count($authorEntry == 2)) {
                     $author = $authorEntry[1] . ' ' . $authorEntry[0];
                 }
                 $authorString .= $author;
                 if ($totalAuths > 1 && $x < $totalAuths - 1) {
                     $authorString .= ',';
                 }
                 $x = $x + 1;
             }
             $view->authorString = $authorString;
         }
         //tags & badges
         $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false);
         $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false);
     }
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     return $view->loadTemplate();
 }
示例#17
0
 /**
  * Display product
  *
  * @param		$pId
  * @return     	void
  */
 public function displayTask()
 {
     $productIdentifier = Request::getVar('product', '');
     $pInfo = $this->warehouse->checkProduct($productIdentifier);
     if (!$pInfo->status) {
         App::abort($pInfo->errorCode, Lang::txt($pInfo->message));
     }
     $pId = $pInfo->pId;
     $this->view->pId = $pId;
     $this->view->css();
     $this->view->js('product_display.js');
     // A flag whether the item is available for purchase (for any reason, used by the auditors)
     $productAvailable = true;
     $pageMessages = array();
     // Get the cart
     $cart = new CurrentCart();
     // POST add to cart request
     $addToCartRequest = Request::getVar('addToCart', false, 'post');
     $options = Request::getVar('og', false, 'post');
     $qty = Request::getInt('qty', 1, 'post');
     if ($addToCartRequest) {
         // Initialize errors array
         $errors = array();
         // Check if passed options/productID map to a SKU
         try {
             $sku = $this->warehouse->mapSku($pId, $options);
             $cart->add($sku, $qty);
         } catch (\Exception $e) {
             $errors[] = $e->getMessage();
             $pageMessages[] = array($e->getMessage(), 'error');
         }
         if (!empty($errors)) {
             $this->view->setError($errors);
         } else {
             // prevent resubmitting by refresh
             // If not an ajax call, redirect to cart
             App::redirect(Route::url('index.php?option=com_cart'));
         }
     }
     // Get the product info
     $product = $this->warehouse->getProductInfo($pId);
     $this->view->product = $product;
     // Run the auditor
     $auditor = Audit::getAuditor($product, $cart->getCartInfo()->crtId);
     $auditorResponse = $auditor->audit();
     //print_r($auditorResponse); die;
     if (!empty($auditorResponse) && $auditorResponse->status != 'ok') {
         if ($auditorResponse->status == 'error') {
             // Product is not available for purchase
             $productAvailable = false;
             foreach ($auditorResponse->notices as $notice) {
                 $pageMessages[] = array($notice, 'warning');
             }
         }
     }
     // Get option groups with options and SKUs
     $data = $this->warehouse->getProductOptions($pId);
     //print_r($data); die;
     if ($data) {
         //App::abort(404 , Lang::txt('COM_STOREFRONT_PRODUCT_ERROR'));
         $this->view->options = $data->options;
     }
     //print_r($data); die;
     // Find a price range for the product
     $priceRange = array('high' => 0, 'low' => false);
     /*
     	Find if there is a need to display a product quantity dropdown on the initial view load. It will be only displayed for single SKU that allows multiple items.
     	For multiple SKUs it will be generated by JS (no drop-down for non-JS users, sorry)
     */
     $qtyDropDownMaxVal = 0;
     $inStock = true;
     if (!$data || !count($data->skus)) {
         $inStock = false;
     }
     $this->view->inStock = $inStock;
     if ($data && count($data->skus) == 1) {
         // Set the max value for the dropdown QTY
         // TODO: add it to the SKU table to set on the per SKU level
         $qtyDropDownMaxValLimit = 20;
         // Get the first and the only value
         $arrayValues = array_values($data->skus);
         $sku = array_shift($arrayValues);
         // If no inventory tracking, there is no limit on how many can be purchased
         $qtyDropDownMaxVal = $qtyDropDownMaxValLimit;
         if ($sku['info']->sTrackInventory) {
             $qtyDropDownMaxVal = $sku['info']->sInventory;
         }
         if ($qtyDropDownMaxVal < 1) {
             $qtyDropDownMaxVal = 1;
         } elseif ($qtyDropDownMaxVal > $qtyDropDownMaxValLimit) {
             $qtyDropDownMaxVal = $qtyDropDownMaxValLimit;
         }
         // If the SKU doesn't allow multiple items, set the dropdown to 1
         if (!$sku['info']->sAllowMultiple) {
             $qtyDropDownMaxVal = 1;
         }
     }
     $this->view->qtyDropDown = $qtyDropDownMaxVal;
     if ($data) {
         foreach ($data->skus as $sId => $info) {
             $info = $info['info'];
             if ($info->sPrice > $priceRange['high']) {
                 $priceRange['high'] = $info->sPrice;
             }
             if (!$priceRange['low'] || $priceRange['low'] > $info->sPrice) {
                 $priceRange['low'] = $info->sPrice;
             }
         }
     }
     $this->view->price = $priceRange;
     // Add custom page JS
     if ($data && (count($data->options) > 0 || count($data->skus) > 1)) {
         $js = $this->getDisplayJs($data->options, $data->skus, $productIdentifier);
         Document::addScriptDeclaration($js);
     }
     $this->view->config = $this->config;
     $this->view->productAvailable = $productAvailable;
     //build pathway
     $this->_buildPathway($product->pName);
     // Set notifications
     $this->view->notifications = $pageMessages;
     $this->view->display();
 }
示例#18
0
$script .= 'var title = document.getElementById("title").value;' . "\n\t";
$script .= 'if (title != \'\') {' . "\n\t\t";
$script .= 'title = "title=\\""+title+"\\" ";' . "\n\t";
$script .= '}' . "\n\t";
// Get the pagebreak toc alias -- not inserting for now
// don't know which attribute to use...
$script .= 'var alt = document.getElementById("alt").value;' . "\n\t";
$script .= 'if (alt != \'\') {' . "\n\t\t";
$script .= 'alt = "alt=\\""+alt+"\\" ";' . "\n\t";
$script .= '}' . "\n\t";
$script .= 'var tag = "<hr class=\\"system-pagebreak\\" "+title+" "+alt+"/>";' . "\n\t";
$script .= 'window.parent.jInsertEditorText(tag, \'' . $this->eName . '\');' . "\n\t";
$script .= 'window.parent.$.fancybox.close();' . "\n\t";
$script .= 'return false;' . "\n";
$script .= '}' . "\n";
Document::addScriptDeclaration($script);
?>
	<form>
		<table>
			<tr>
				<th>
					<label for="title">
						<?php 
echo Lang::txt('COM_CONTENT_PAGEBREAK_TITLE');
?>
					</label>
				</th>
				<td>
					<input type="text" id="title" name="title" />
				</td>
			</tr>
示例#19
0
 /**
  * Method to get the user field input markup.
  *
  * @return  string  The field input markup.
  */
 public static function getUserInput($name, $id, $value, $class = null, $size = null, $onchange = null, $readonly = false)
 {
     // Initialize variables.
     $html = array();
     $link = Route::url('index.php?option=com_members&controller=members&task=modal&tmpl=component&field=' . $id);
     // Initialize some field attributes.
     $attr = $class ? ' class="' . (string) $class . '"' : '';
     $attr .= $size ? ' size="' . (int) $size . '"' : '';
     // Initialize JavaScript field attributes.
     $onchange = (string) $onchange;
     // Load the modal behavior script.
     Html::behavior('modal', 'a.modal_' . $id);
     // Build the script.
     $script = array();
     $script[] = '	function jSelectUser_' . $id . '(id, title) {';
     $script[] = '		var old_id = document.getElementById("' . $id . '_id").value;';
     $script[] = '		if (old_id != id) {';
     $script[] = '			document.getElementById("' . $id . '_id").value = id;';
     $script[] = '			document.getElementById("' . $id . '_name").value = title;';
     $script[] = '			' . $onchange;
     $script[] = '		}';
     $script[] = '		$.fancybox.close();';
     $script[] = '	}';
     // Add the script to the document head.
     Document::addScriptDeclaration(implode("\n", $script));
     // Load the current username if available.
     $user = User::getInstance($value);
     if (!$user || !$user->get('id')) {
         $user->set('name', Lang::txt('JLIB_FORM_SELECT_USER'));
     }
     // Create a dummy text field with the user name.
     if (!$readonly) {
         $html[] = '<div class="input-modal">';
         $html[] = '	<span class="input-cell">';
     }
     $html[] = '		<input type="text" id="' . $id . '_name"' . ' value="' . htmlspecialchars($user->get('name'), ENT_COMPAT, 'UTF-8') . '" disabled="disabled"' . $attr . ' />';
     // Create the user select button.
     if (!$readonly) {
         $html[] = '	</span>';
         $html[] = '	<span class="input-cell">';
         $html[] = '		<a class="button modal_' . $id . '" title="' . Lang::txt('JLIB_FORM_CHANGE_USER') . '"' . ' href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
         $html[] = '			' . Lang::txt('JLIB_FORM_CHANGE_USER');
         $html[] = '		</a>';
         $html[] = '	</span>';
         $html[] = '</div>';
     }
     // Create the real field, hidden, that stored the user id.
     $html[] = '<input type="hidden" id="' . $id . '_id" name="' . $name . '" value="' . (int) $value . '" />';
     return implode("\n", $html);
 }
示例#20
0
 /**
  * @param	string	$id
  *
  * @return	string
  */
 public function onGetInsertMethod($id)
 {
     static $done = false;
     // Do this only once.
     if (!$done) {
         $js = "\tfunction jInsertEditorText(text, editor) {\n\t\t\t\tinsertAtCursor(document.getElementById(editor), text);\n\t\t\t}";
         Document::addScriptDeclaration($js);
     }
     return true;
 }
示例#21
0
 /**
  * Display product
  *
  * @param		$pId
  * @return     	void
  */
 public function displayTask()
 {
     $pId = $this->warehouse->productExists(Request::getVar('product', ''));
     if (!$pId) {
         App::abort(404, Lang::txt('COM_STOREFRONT_PRODUCT_NOT_FOUND'));
     }
     $this->view->pId = $pId;
     $this->view->css();
     $this->view->js('product_display.js');
     // A flag whether the item is available for purchase (for any reason, used by the auditors)
     $productAvailable = true;
     $pageMessages = array();
     // Get the cart
     require_once PATH_CORE . DS . 'components' . DS . 'com_cart' . DS . 'models' . DS . 'CurrentCart.php';
     $cart = new CartModelCurrentCart();
     // POST add to cart request
     $addToCartRequest = Request::getVar('addToCart', false, 'post');
     $options = Request::getVar('og', false, 'post');
     $qty = Request::getInt('qty', 1, 'post');
     if ($addToCartRequest) {
         // Initialize errors array
         $errors = array();
         // Check if passed options/productID map to a SKU
         try {
             $sku = $this->warehouse->mapSku($pId, $options);
             $cart->add($sku, $qty);
         } catch (Exception $e) {
             $errors[] = $e->getMessage();
             $pageMessages[] = array($e->getMessage(), 'error');
         }
         if (!empty($errors)) {
             $this->view->setError($errors);
         } else {
             // prevent resubmitting by refresh
             // If not an ajax call, redirect to cart
             $redirect_url = Route::url('index.php?option=' . 'com_cart');
             App::redirect($redirect_url);
         }
     }
     // Get the product info
     $product = $this->warehouse->getProductInfo($pId);
     $this->view->product = $product;
     // Run the auditor
     require_once PATH_CORE . DS . 'components' . DS . 'com_cart' . DS . 'helpers' . DS . 'Audit.php';
     $auditor = Audit::getAuditor($product, $cart->getCartInfo()->crtId);
     $auditorResponse = $auditor->audit();
     //print_r($auditor); die;
     if (!empty($auditorResponse) && $auditorResponse->status != 'ok') {
         if ($auditorResponse->status == 'error') {
             // Product is not available for purchase
             $productAvailable = false;
             foreach ($auditorResponse->notices as $notice) {
                 $pageMessages[] = array($notice, 'warning');
             }
         }
     }
     // Get option groups with options and SKUs
     $data = $this->warehouse->getProductOptions($pId);
     if ($data) {
         //throw new Exception(Lang::txt('COM_STOREFRONT_PRODUCT_ERROR'), 404);
         $this->view->options = $data->options;
     }
     //print_r($data); die;
     // Find a price range for the product
     $priceRange = array('high' => 0, 'low' => false);
     /*
     	Find if there is a need to display a product quantity dropdown on the initial view load. It will be only displayed for single SKU that allows multiple items.
     	For multiple SKUs it will be generated by JS (no drop-down for non-JS users, sorry)
     */
     $qtyDropDownMaxVal = 0;
     $inStock = true;
     if (!$data || !count($data->skus)) {
         $inStock = false;
     }
     $this->view->inStock = $inStock;
     if ($data && count($data->skus) == 1) {
         // Set the max value for the dropdown QTY
         // TODO: add it to the SKU table to set on the per SKU level
         $qtyDropDownMaxValLimit = 20;
         // Get the first and the only value
         $sku = array_shift(array_values($data->skus));
         // If no inventory tracking, there is no limit on how many can be purchased
         $qtyDropDownMaxVal = $qtyDropDownMaxValLimit;
         if ($sku['info']->sTrackInventory) {
             $qtyDropDownMaxVal = $sku['info']->sInventory;
         }
         if ($qtyDropDownMaxVal < 1) {
             $qtyDropDownMaxVal = 1;
         } elseif ($qtyDropDownMaxVal > $qtyDropDownMaxValLimit) {
             $qtyDropDownMaxVal = $qtyDropDownMaxValLimit;
         }
         // If the SKU doesn't allow multiple items, set the dropdown to 1
         if (!$sku['info']->sAllowMultiple) {
             $qtyDropDownMaxVal = 1;
         }
     }
     $this->view->qtyDropDown = $qtyDropDownMaxVal;
     if ($data) {
         foreach ($data->skus as $sId => $info) {
             $info = $info['info'];
             if ($info->sPrice > $priceRange['high']) {
                 $priceRange['high'] = $info->sPrice;
             }
             if (!$priceRange['low'] || $priceRange['low'] > $info->sPrice) {
                 $priceRange['low'] = $info->sPrice;
             }
         }
     }
     $this->view->price = $priceRange;
     // Add custom page JS
     if ($data && (count($data->options) > 1 || count($data->skus) > 1)) {
         $js = $this->getDisplayJs($data->options, $data->skus);
         Document::addScriptDeclaration($js);
     }
     // Get images (if any), gets all images from /site/storefront/products/$pId
     $allowedImgExt = array('jpg', 'gif', 'png');
     $productImg = array();
     $imgWebPath = DS . 'site' . DS . 'storefront' . DS . 'products' . DS . $pId;
     $imgPath = PATH_APP . $imgWebPath;
     if (file_exists($imgPath)) {
         $files = scandir($imgPath);
         foreach ($files as $file) {
             if (in_array(pathinfo($file, PATHINFO_EXTENSION), $allowedImgExt)) {
                 if (substr($file, 0, 7) == 'default') {
                     // Let the default image to be the first one
                     array_unshift($productImg, $imgWebPath . DS . $file);
                 } else {
                     $productImg[] = $imgWebPath . DS . $file;
                 }
             }
         }
     } else {
         $productImg[] = DS . 'site' . DS . 'storefront' . DS . 'products' . DS . 'noimage.png';
     }
     $this->view->productImg = $productImg;
     $this->view->productAvailable = $productAvailable;
     //build pathway
     $this->_buildPathway($product->pName);
     // Set notifications
     $this->view->notifications = $pageMessages;
     $this->view->display();
 }
示例#22
0
 /**
  * @param   string  $name
  * @return  boolean
  */
 public function onGetInsertMethod($name)
 {
     $js = "\n\t\t\tfunction isBrowserIE() {\n\t\t\t\treturn navigator.appName==\"Microsoft Internet Explorer\";\n\t\t\t}\n\n\t\t\tfunction jInsertEditorText( text, editor ) {\n\t\t\t\tif (isBrowserIE()) {\n\t\t\t\t\tif (window.parent.tinyMCE) {\n\t\t\t\t\t\twindow.parent.tinyMCE.selectedInstance.selection.moveToBookmark(window.parent.global_ie_bookmark);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttinyMCE.execInstanceCommand(editor, 'mceInsertContent',false,text);\n\t\t\t}\n\n\t\t\tvar global_ie_bookmark = false;\n\n\t\t\tfunction IeCursorFix() {\n\t\t\t\tif (isBrowserIE()) {\n\t\t\t\t\ttinyMCE.execCommand('mceInsertContent', false, '');\n\t\t\t\t\tglobal_ie_bookmark = tinyMCE.activeEditor.selection.getBookmark(false);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}";
     Document::addScriptDeclaration($js);
     return true;
 }
示例#23
0
    /**
     * Generate macro output
     *
     * @return     string
     */
    public function render()
    {
        //get the args passed in
        $content = $this->args;
        // args will be null if the macro is called without parenthesis.
        if (!$content) {
            return;
        }
        //generate a unique id for the slider
        $id = uniqid();
        // null base url for now
        $base_url = '';
        // needed objects
        $db = \App::get('db');
        $option = \Request::getCmd('option');
        $config = \Component::params($option);
        // define a base url
        switch ($option) {
            case 'com_groups':
                $cn = \Request::getVar('cn');
                $group = Group::getInstance($cn);
                $base_url = DS . trim($config->get('uploadpath', 'site/groups'), DS) . DS;
                $base_url .= $group->get('gidNumber') . DS . 'uploads';
                break;
            case 'com_resources':
                $row = new \Components\Resources\Tables\Resource($db);
                $row->load($this->pageid);
                $base_url = DS . trim($config->get('uploadpath', 'site/resources'), DS) . DS;
                $base_url .= \Components\Resources\Helpers\Html::build_path($row->created, $this->pageid, '') . DS . 'media';
                break;
        }
        //seperate image list into array of images
        $slides = array_map('trim', explode(',', $content));
        //array for checked slides
        $final_slides = array();
        //check each passed in slide
        foreach ($slides as $slide) {
            //check to see if image is external
            if (strpos($slide, 'http') === false) {
                $slide = trim($slide);
                //check if internal file actually exists
                if (is_file(PATH_APP . $base_url . DS . $slide)) {
                    $final_slides[] = $base_url . DS . $slide;
                }
            } else {
                $headers = get_headers($slide);
                if (strpos($headers[0], "OK") !== false) {
                    $final_slides[] = $slide;
                }
            }
        }
        $html = '';
        $html .= '<div class="wiki_slider">';
        $html .= '<div id="slider_' . $id . '">';
        foreach ($final_slides as $fs) {
            $html .= '<img src="' . $fs . '" alt="" />';
        }
        $html .= '</div>';
        $html .= '<div class="wiki_slider_pager" id="slider_' . $id . '_pager"></div>';
        $html .= '</div>';
        \Document::addStyleSheet('plugins/content/formathtml/macros/macro-assets/slider/slider.css');
        \Document::addScript('plugins/content/formathtml/macros/macro-assets/slider/slider.js');
        \Document::addScriptDeclaration('
			var $jQ = jQuery.noConflict();

			$jQ(function() {
				$jQ("#slider_' . $id . '").cycle({
					fx: \'scrollHorz\',
					speed: 450,
					pager: \'#slider_' . $id . '_pager\'
				});
			});
		');
        return $html;
    }
示例#24
0
    /**
     * Generate macro output
     *
     * @return     string
     */
    public function render()
    {
        //get the args passed in
        $content = $this->args;
        // args will be null if the macro is called without parenthesis.
        if (!$content) {
            return;
        }
        //generate a unique id for the slider
        $id = uniqid();
        //get the group
        $gid = Request::getVar('cn');
        //get the group object based on gid
        $group = \Hubzero\User\Group::getInstance($gid);
        //check to make sure we have a valid group
        if (!is_object($group)) {
            return;
        }
        //define a base url
        $base_url = DS . 'site' . DS . 'groups' . DS . $group->get('gidNumber');
        //seperate image list into array of images
        $slides = explode(',', $content);
        //array for checked slides
        $final_slides = array();
        //check each passed in slide
        foreach ($slides as $slide) {
            //check to see if image is external
            if (strpos($slide, 'http') === false) {
                $slide = trim($slide);
                //check if internal file actually exists
                if (is_file(PATH_APP . $base_url . DS . $slide)) {
                    $final_slides[] = $base_url . DS . $slide;
                }
            } else {
                $headers = get_headers($slide);
                if (strpos($headers[0], "OK") !== false) {
                    $final_slides[] = $slide;
                }
            }
        }
        $html = '';
        $html .= '<div class="wiki_slider">';
        $html .= '<div id="slider_' . $id . '">';
        foreach ($final_slides as $fs) {
            $html .= '<img src="' . $fs . '" alt="" />';
        }
        $html .= '</div>';
        $html .= '<div class="wiki_slider_pager" id="slider_' . $id . '_pager"></div>';
        $html .= '</div>';
        Document::addStyleSheet('plugins/wiki/parserdefault/macros/macro-assets/slider/slider.css');
        Document::addScript('plugins/wiki/parserdefault/macros/macro-assets/slider/slider.js');
        Document::addScriptDeclaration('
			jQuery(document).ready(function($) {
				$("#slider_' . $id . '").cycle({
					fx: \'scrollHorz\',
					speed: 450,
					pager: \'#slider_' . $id . '_pager\'
				});
			});
		');
        return $html;
    }
示例#25
0
 /**
  * Return data on a group view (this will be some form of HTML)
  *
  * @param   object   $group       Current group
  * @param   string   $option      Name of the component
  * @param   string   $authorized  User's authorization level
  * @param   integer  $limit       Number of records to pull
  * @param   integer  $limitstart  Start of records to pull
  * @param   string   $action      Action to perform
  * @param   array    $access      What can be accessed
  * @param   array    $areas       Active area(s)
  * @return  array
  */
 public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null)
 {
     $return = 'html';
     $active = 'usage';
     // The output array we're returning
     $arr = array('html' => '');
     //get this area details
     $this_area = $this->onGroupAreas();
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas) && $limit) {
         if (!in_array($this_area['name'], $areas)) {
             $return = '';
         }
     }
     if ($return == 'html') {
         //set group members plugin access level
         $group_plugin_acl = $access[$active];
         //get the group members
         $members = $group->get('members');
         //if set to nobody make sure cant access
         if ($group_plugin_acl == 'nobody') {
             $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_OFF', ucfirst($active)) . '</p>';
             return $arr;
         }
         //check if guest and force login if plugin access is registered or members
         if (User::isGuest() && ($group_plugin_acl == 'registered' || $group_plugin_acl == 'members')) {
             $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true);
             App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active)), 'warning');
             return;
         }
         //check to see if user is member and plugin access requires members
         if (!in_array(User::get('id'), $members) && $group_plugin_acl == 'members' && $authorized != 'admin') {
             $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>';
             return $arr;
         }
         //instantiate the db
         $database = App::get('db');
         //reference group for other functions
         $this->group = $group;
         //add usage stylesheet to view
         $this->css();
         //add datepicker stylesheet to view
         $this->css('jquery.datepicker.css', 'system')->css('jquery.timepicker.css', 'system');
         //add google js-api
         Document::addScript('https://www.google.com/jsapi');
         //add jquery from google cdn
         //Document::addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js');
         //add usage custom script
         $this->js('usage.js');
         //add datepicker script
         //$this->js('datepicker.js');
         //get the page id if we want to view stats on a specific page
         $pid = Request::getVar('pid', '');
         //get start and end dates
         $start = Request::getVar('start', gmdate("Y-m-d 00:00:00", strtotime('-30 DAYS')));
         $end = Request::getVar('end', gmdate("Y-m-d 23:59:59"));
         if (preg_match('/\\d{2}\\/\\d{2}\\/\\d{4}/', $start)) {
             $start = Date::of($start)->format('Y-m-d') . ' 00:00:00';
         }
         if (preg_match('/\\d{2}\\/\\d{2}\\/\\d{4}/', $end)) {
             $end = Date::of($end)->format('Y-m-d') . ' 00:00:00';
         }
         //make sure start date is a full php datetime
         if (strlen($start) != 19) {
             $start .= " 00:00:00";
         }
         //make sure end date is a full php datetime
         if (strlen($end) != 19) {
             $end .= " 23:59:59";
         }
         //generate script to draw chart and push to the page
         $script = $this->drawChart($pid, $start, $end);
         Document::addScriptDeclaration($script);
         //import and create view
         $view = $this->view('default', 'index');
         //get the group pages
         $query = "SELECT id, title FROM `#__xgroups_pages` WHERE state=1 AND gidNumber=" . $database->quote($group->get('gidNumber'));
         $database->setQuery($query);
         $view->pages = $database->loadAssocList();
         $view->option = $option;
         $view->group = $group;
         $view->authorized = $authorized;
         $view->database = $database;
         $view->pid = $pid;
         $view->start = $start;
         $view->end = $end;
         foreach ($this->getErrors() as $error) {
             $view->setError($error);
         }
         $arr['html'] = $view->loadTemplate();
     }
     return $arr;
 }
示例#26
0
 /**
  * @param	string	$id
  * @return	string
  */
 public function onGetInsertMethod($id)
 {
     $js = "\n\t\t\tfunction jInsertEditorText( text, editor ) {\n\t\t\t\tCKEDITOR.instances[editor].updateElement();\n\t\t\t\tvar content = document.getElementById(editor).value;\n\t\t\t\tcontent = content + text;\n\t\t\t\tCKEDITOR.instances[editor].setData(content);\n\t\t\t}\n\t\t";
     Document::addScriptDeclaration($js);
     return true;
 }
示例#27
0
 /**
  * Display the form allowing to edit a citation
  *
  * @return		 string HTML
  */
 private function _edit()
 {
     // create view object
     $view = $this->view('default', 'edit');
     // Check if they're logged in
     if (User::isGuest()) {
         $this->_loginTask();
     }
     // push objects to view
     $view->group = $this->group;
     $view->isManager = $this->authorized == 'manager' ? true : false;
     $view->config = new \Hubzero\Config\Registry($this->group->get('params'));
     if ($view->isManager == false) {
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_GROUP_MANAGER_ONLY'), 'warning');
     }
     // get the citation types
     $citationsType = \Components\Citations\Models\Type::all();
     $view->types = $citationsType->rows()->toObject();
     $fields = array();
     foreach ($view->types as $type) {
         if (isset($type->fields)) {
             $f = $type->fields;
             if (strpos($f, ',') !== false) {
                 $f = str_replace(',', "\n", $f);
             }
             $f = array_map('trim', explode("\n", $f));
             $f = array_values(array_filter($f));
             $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f;
         }
     }
     // Incoming - expecting an array id[]=4232
     $id = Request::getInt('id', 0);
     // Pub author
     $pubAuthor = false;
     // Is user authorized to edit citations?
     if (!$view->isManager && !$pubAuthor) {
         $id = 0;
     }
     // Load the object
     $view->row = \Components\Citations\Models\Citation::oneorNew($id);
     // make sure title isnt too long
     $maxTitleLength = 30;
     $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '&hellip;' : $view->row->title;
     // Set the pathway
     if ($id && $id != 0) {
         Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id);
         Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_EDIT'));
     } else {
         Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_ADD'));
     }
     // non-owner redirect
     if (!$view->row->isNew() && $view->row->scope != 'group') {
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_PERMISSION_DENIED'), 'warning');
     }
     // Set the page title
     Document::setTitle(Lang::txt('PLG_GROUPS_CITATIONS_CITATION') . $shortenedTitle);
     // push jquery to doc
     Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';');
     // Instantiate a new view
     $view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->action));
     // No ID, so we're creating a new entry
     // Set the ID of the creator
     if (!$id) {
         $view->row->uid = User::get('id');
         // tags & badges
         $view->tags = array();
         $view->badges = array();
         $view->row->id = -time();
     } else {
         if ($view->row->relatedAuthors->count()) {
             $view->authors = $view->row->relatedAuthors;
         } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') {
             // formats the author for the multi-author plugin
             $authors = explode(';', $view->row->author);
             $authorString = '';
             $totalAuths = count($authors);
             $x = 0;
             foreach ($authors as &$author) {
                 /***
                  * Because the multi-select keys off of a comma,
                  * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select
                  * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to
                  * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME})
                  ***/
                 $authorEntry = explode(',', $author);
                 if (count($authorEntry) == 2) {
                     $author = $authorEntry[1] . ' ' . $authorEntry[0];
                 }
                 $authorString .= $author;
                 if ($totalAuths > 1 && $x < $totalAuths - 1) {
                     $authorString .= ',';
                 }
                 $x = $x + 1;
             }
             $view->authorString = $authorString;
         }
         // tags & badges
         $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false);
         $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false);
     }
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     return $view->loadTemplate();
 }