Example #1
0
 /**
  * Method to get the HTML of this element
  *
  * @param null
  * @return string
  */
 protected function getInput()
 {
     $name = $this->name;
     $value = $this->value;
     $id = preg_replace('/([^0-9a-zA-Z]+)/', '_', $name);
     // Are the API widgets enabled?
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         // Load the javascript
         JHTML::script('media/com_magebridge/js/backend-elements.js');
         JHTML::_('behavior.modal', 'a.modal');
         $returnType = (string) $this->element['return'];
         $allowRoot = (string) $this->element['allow_root'];
         $title = $value;
         $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
         $link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1';
         $link .= '&type=category&object=' . $id . '&return=' . $returnType;
         $link .= '&allow_root=' . $allowRoot . '&current=' . $value;
         $html = array();
         if (YireoHelper::isJoomla25()) {
             $html[] = '<div style="float: left;">';
             $html[] = '<input type="text" id="' . $id . '" name="' . $name . '" value="' . $title . '" />';
             $html[] = '</div>';
             $html[] = '<div class="button2-left"><div class="blank">';
             $html[] = '<a class="modal btn" title="' . JText::_('JSELECT') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('JSELECT') . '</a>';
             $html[] = '</div></div>' . "\n";
         } else {
             $html[] = '<span class="input-append">';
             $html[] = '<input type="text" class="input-medium" id="' . $id . '" name="' . $name . '" value="' . $title . '" size="35" />';
             $html[] = '<a class="modal btn" role="button" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
             $html[] = '</span>';
         }
         $html = implode("\n", $html);
         return $html;
     }
     return '<input type="text" name="' . $name . '" value="' . $value . '" />';
 }
Example #2
0
<?php

/**
 * Joomla! Yireo Library
 *
 * @author Yireo
 * @package YireoLib
 * @copyright Copyright 2015
 * @license GNU Public License
 * @link http://www.yireo.com/
 * @version 0.5.0
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;
if (YireoHelper::isJoomla25()) {
    ?>
	<div class="filter-search">
		<label class="filter-search-lbl" for="search"><?php 
    echo JText::_('LIB_YIREO_VIEW_FILTER');
    ?>
</label>
		<input type="text" name="filter_search" value="<?php 
    echo $this->search;
    ?>
" id="search" class="text_area"
			placeholder="<?php 
    echo JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_SEARCH_INPUT');
    ?>
" />
		<button class="btn" onclick="this.form.submit();"><?php 
    echo JText::_('LIB_YIREO_VIEW_SEARCH');
Example #3
0
 /**
  * Method to get data
  *
  * @access public
  * @subpackage Yireo
  * @param null
  * @return array
  */
 public function getData($forceNew = false)
 {
     // Load the data if they are not just set or if the force-flag is set
     if ($this->_data === null || $forceNew == self::FORCE_NEW) {
         // Load some empty data-set
         $this->getEmpty();
         // Try to load the temporary data from this session
         $this->loadTmpSession();
         // Singular model
         if ($this->isSingular() && $this->getId() > 0) {
             $query = $this->buildQuery();
             $data = $this->getDbResult($query, 'object');
             if (!empty($data)) {
                 // Prepare the column-fields
                 if (!empty($this->_columnFields)) {
                     foreach ($this->_columnFields as $columnField) {
                         if (!empty($data->{$columnField}) && !is_array($data->{$columnField})) {
                             $data->{$columnField} = explode('|', $data->{$columnField});
                         }
                     }
                 }
                 // Allow to modify the data
                 if (method_exists($this, 'onDataLoad')) {
                     $data = $this->onDataLoad($data);
                 }
                 // Set the ID
                 $key = $this->getPrimaryKey();
                 $data->id = $data->{$key};
                 $data->metadata = $this->getMetadata();
                 $this->_data = $data;
             } else {
                 $data = (object) null;
             }
             // Check to see if the data is published
             $stateField = $this->_tbl->getStateField();
             if ($this->app->isSite() && isset($data->{$stateField}) && $data->{$stateField} == 0) {
                 JError::raiseError(404, JText::_('LIB_YIREO_MODEL_NOT_FOUND'));
                 return;
             }
             // Fill in non-existing fields
             foreach ($this->getEmptyFields() as $fieldName => $fieldValue) {
                 if (!isset($data->{$fieldName})) {
                     $data->{$fieldName} = $fieldValue;
                 }
             }
             // Plural model
         } else {
             if ($this->isSingular() == false) {
                 $query = $this->buildQuery();
                 $data = $this->getDbResult($query, 'objectList');
                 if (!empty($data)) {
                     // Prepare these data
                     foreach ($data as $index => $item) {
                         // Frontend permissions
                         if ($this->app->isSite() && isset($item->access) && is_numeric($item->access)) {
                             $accessLevels = $this->user->getAuthorisedViewLevels();
                             if (YireoHelper::isJoomla25()) {
                                 if (!array_key_exists($item->access, $accessLevels) || $accessLevels[$item->access] == 0) {
                                     unset($data[$index]);
                                     continue;
                                 }
                             } else {
                                 if ($item->access > 0 && !in_array($item->access, $accessLevels)) {
                                     unset($data[$index]);
                                     continue;
                                 }
                             }
                         }
                         // Backend permissions
                         if ($this->app->isAdmin() && (bool) $this->_tbl->hasAssetId() == true) {
                             // Get the ID
                             $key = $this->getPrimaryKey();
                             $id = $item->{$key};
                             // Determine the owner
                             $owner = 0;
                             if (!empty($item->created_by)) {
                                 $owner = (int) $item->created_by;
                             } elseif (!empty($item->modified_by)) {
                                 $owner = (int) $item->modified_by;
                             } elseif (!empty($item->owned_by)) {
                                 $owner = (int) $item->owned_by;
                             }
                             if ($owner == 0) {
                                 $owner = $this->user->id;
                             }
                             // Get the ACL rules
                             $canEdit = $this->user->authorise('core.edit', $this->_option);
                             $canEditOwn = $this->user->authorise('core.edit.own', $this->_option);
                             // Determine authorisation
                             $authorise = false;
                             if ($canEdit) {
                                 $authorise = true;
                             } elseif ($canEditOwn && $owner == $this->user->id) {
                                 $authorise = true;
                             }
                             // Authorise
                             if ($authorise == false) {
                                 unset($data[$index]);
                                 continue;
                             }
                         }
                         // Prepare the column-fields
                         if (!empty($this->_columnFields)) {
                             foreach ($this->_columnFields as $columnField) {
                                 if (!empty($item->{$columnField}) && !is_array($item->{$columnField})) {
                                     $item->{$columnField} = explode('|', $item->{$columnField});
                                 }
                             }
                         }
                         // Prepare the parameters
                         if (isset($item->params)) {
                             $item->params = YireoHelper::toParameter($item->params);
                         } else {
                             $item->params = YireoHelper::toParameter();
                         }
                         // Check for publish_up and publish_down
                         if ($this->app->isSite()) {
                             $publish_up = $item->params->get('publish_up');
                             $publish_down = $item->params->get('publish_down');
                             if (!empty($publish_up) && strtotime($publish_up) > time()) {
                                 unset($data[$index]);
                                 continue;
                             } else {
                                 if (!empty($publish_down) && strtotime($publish_down) < time()) {
                                     unset($data[$index]);
                                     continue;
                                 }
                             }
                         }
                         // Allow to modify the data
                         if (method_exists($this, 'onDataLoad')) {
                             $item = $this->onDataLoad($item);
                         }
                         // Add the metadata
                         $item->metadata = $this->getMetadata();
                         // Set the ID
                         $key = $this->getPrimaryKey();
                         $item->id = $item->{$key};
                         // Fill in non-existing fields
                         foreach ($this->getEmptyFields() as $fieldName => $fieldValue) {
                             if (!isset($item->{$fieldName})) {
                                 $item->{$fieldName} = $fieldValue;
                             }
                         }
                         // Re-insert this item
                         $data[$index] = $item;
                     }
                     if ($this->_limit_query == false) {
                         $this->_total = count($data);
                     }
                     $this->_data = $data;
                 }
             }
         }
         // Allow to modify the data afterwards
         if (method_exists($this, 'onDataLoadAfter')) {
             $data = $this->onDataLoadAfter($data);
         }
     }
     if ($this->isSingular() == false && $this->_limit_query == false && $this->getState('limit') > 0) {
         $part = array_slice($this->_data, $this->getState('limitstart'), $this->getState('limit'));
         return $part;
     }
     return $this->_data;
 }
Example #4
0
 public static function jquery()
 {
     // Do not load when having no HTML-document
     $document = JFactory::getDocument();
     if (stristr(get_class($document), 'html') == false) {
         return;
     }
     // Load jQuery using the framework (Joomla! 3.0 and higher)
     if (YireoHelper::isJoomla25() == false) {
         return JHtml::_('jquery.framework');
     }
     // Check if jQuery is loaded already
     $application = JFactory::getApplication();
     if (method_exists($application, 'get') && $application->get('jquery') == true) {
         return;
     }
     // Do not load this for specific extensions
     if (JFactory::getApplication()->input->getCmd('option') == 'com_virtuemart') {
         return false;
     }
     // Load jQuery
     $option = JFactory::getApplication()->input->getCmd('option');
     if (file_exists(JPATH_SITE . '/media/' . $option . '/js/jquery.js')) {
         $document->addScript(JURI::root() . 'media/' . $option . '/js/jquery.js');
         $document->addCustomTag('<script type="text/javascript">jQuery.noConflict();</script>');
         // Set the flag that jQuery has been loaded
         if (method_exists($application, 'set')) {
             $application->set('jquery', true);
         }
     }
 }
Example #5
0
         <?php 
 if ($auto_columns) {
     ?>
         <?php 
     if ($hasState) {
         ?>
         <td>
             <?php 
         echo $published;
         ?>
         </td>
         <?php 
     }
     ?>
         <?php 
     if ($hasOrdering && YireoHelper::isJoomla25()) {
         ?>
         <td class="order">
             <?php 
         if (isset($item->hasOrdering) && $item->hasOrdering == false) {
             ?>
                 <?php 
             echo $this->getImageTag('disabled.png');
             ?>
             <?php 
         } else {
             ?>
                 <?php 
             if ($this->pagination) {
                 ?>
                     <span><?php 
Example #6
0
<?php

/**
 * Joomla! Yireo Library
 *
 * @author Yireo
 * @package YireoLib
 * @copyright Copyright 2015
 * @license GNU Public License
 * @link http://www.yireo.com/
 * @version 0.5.3
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;
if (YireoHelper::isJoomla25() == false) {
    // Construct the options
    $limits = array(0, 10, 20, 30, 40, 50, 100, 200, 300, 400, 500);
    $options = array();
    foreach ($limits as $limit) {
        $options[] = array('value' => $limit, 'title' => $limit);
    }
    $javascript = 'onchange="document.adminForm.submit();"';
    ?>
<div class="list-limit">
    <?php 
    echo JHTML::_('select.genericlist', $options, 'filter_list_limit', $javascript, 'value', 'title', $this->getFilter('list_limit'));
    ?>
</div>
<?php 
}
Example #7
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.
     JHtml::_('behavior.modal', 'a.modal');
     // Build the script.
     $script = array();
     $script[] = '	function jSelectArticle_' . $this->id . '(id, title, catid, object) {';
     $script[] = '		document.id("' . $this->id . '_id").value = id;';
     $script[] = '		document.id("' . $this->id . '_name").value = title;';
     $script[] = '		SqueezeBox.close();';
     $script[] = '	}';
     $script[] = '	function jResetArticle_' . $this->id . '(id, title, catid, object) {';
     $script[] = '		document.id("' . $this->id . '_id").value = 0;';
     $script[] = '		document.id("' . $this->id . '_name").value = "' . JText::_('COM_CONTENT_SELECT_AN_ARTICLE') . '";';
     $script[] = '	}';
     // Add the script to the document head.
     JFactory::getDocument()->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;
     $link .= '&amp;' . JSession::getFormToken() . '=1';
     // Load the article title
     $db = JFactory::getDBO();
     $db->setQuery('SELECT title FROM #__content WHERE id = ' . (int) $this->value);
     $title = $db->loadResult();
     if (empty($title)) {
         $title = JText::_('COM_CONTENT_SELECT_AN_ARTICLE');
     }
     $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
     // Load the article ID
     $value = $this->value;
     if (0 == (int) $this->value) {
         $value = '';
     } else {
         $value = (int) $this->value;
     }
     // HTML for Joomla! 2.5
     if (YireoHelper::isJoomla25()) {
         // The current user display field
         $html[] = '<div class="fltlft">';
         $html[] = '  <input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
         $html[] = '</div>';
         // The user select button
         $html[] = '<div class="button2-left">';
         $html[] = '  <div class="blank">';
         $html[] = '	<a class="modal btn" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JText::_('COM_CONTENT_CHANGE_ARTICLE_BUTTON') . '</a>';
         $html[] = '  </div>';
         $html[] = '</div>';
         // The reset button
         $html[] = '<div class="button2-left">';
         $html[] = '  <div class="blank">';
         $html[] = '	<a class="btn" onclick="jResetArticle_' . $this->id . '(); return false;">' . JText::_('JNONE') . '</a>';
         $html[] = '  </div>';
         $html[] = '</div>';
         // HTML for other Joomla!
     } else {
         $html[] = '<span class="input-append">';
         $html[] = '<input type="text" class="input-medium" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
         $html[] = '<a class="modal btn" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
         $html[] = '<button id="' . $this->id . '_clear" class="btn" onclick="return jResetArticle_' . $this->id . '();"><span class="icon-remove"></span>' . JText::_('JCLEAR') . '</button>';
         $html[] = '</span>';
     }
     // 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);
 }