Example #1
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $output = '<span class="k2Note">' . JText::_('Click Apply to be able to create product attributes') . '</span>';
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                Tienda::load('TiendaUrl', 'library.url');
                Tienda::load("TiendaHelperProduct", 'helpers.product');
                $attributes = TiendaHelperProduct::getAttributes($productID);
                $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributes&id=" . $productID . "&tmpl=component", JText::_('Set Attributes')) . '</div>';
                $output .= '<div>';
                foreach (@$attributes as $attribute) {
                    $output .= '
					<div>
						<span>' . $attribute->productattribute_name . '(' . $attribute->option_names_csv . ')</span>
						<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributeoptions&id=" . $attribute->productattribute_id . "&tmpl=component", JText::_('Set Attribute Options')) . '</div>
						<div class="tiendaButton"><a href="' . "index.php?option=com_tienda&controller=productattributes&task=delete&cid[]=" . $attribute->productattribute_id . "&return=" . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div>
					</div>';
                }
                $output .= '</div>';
            }
        }
        return $output;
    }
Example #2
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $output = '
		<input type="text" class="text_area" value="" id="pluginstiendaproductPrice" name="plugins[tiendaproductPrice]">
		<span class="k2Note">' . JText::_('Set Normal Price Now Special Prices Later') . '</span>
		';
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                Tienda::load('TiendaUrl', 'library.url');
                Tienda::load("TiendaHelperProduct", 'helpers.product');
                $prices = TiendaHelperProduct::getPrices($productID);
                if (count($prices)) {
                    $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setprices&id=" . $productID . "&tmpl=component", JText::_('COM_TIENDA_SET_PRICES')) . '</div>';
                    $output .= '<div>';
                    foreach (@$prices as $price) {
                        $output .= '
						<div>
							<span>' . TiendaHelperBase::currency($price->product_price) . '</span>
							<div class="tiendaButton"><a href="' . $price->link_remove . '&return=' . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div>
						</div>';
                    }
                    $output .= '</div>';
                }
            }
        }
        return $output;
    }
Example #3
0
 function onRenderAdminForm(&$item, $type, $tab = '')
 {
     $mainframe = JFactory::getApplication();
     $manifest = K2_JVERSION == '15' ? JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . $this->pluginName . '.xml' : JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . $this->pluginName . DS . $this->pluginName . '.xml';
     if (!empty($tab)) {
         $path = $type . '-' . $tab;
     } else {
         $path = $type;
     }
     if (!isset($item->plugins)) {
         $item->plugins = NULL;
     }
     if (K2_JVERSION == '15') {
         $form = new K2Parameter($item->plugins, $manifest, $this->pluginName);
         $fields = $form->render('plugins', $path);
     } else {
         jimport('joomla.form.form');
         $form = JForm::getInstance('plg_k2_' . $this->pluginName . '_' . $path, $manifest, array(), true, 'fields[@group="' . $path . '"]');
         $values = array();
         if ($item->plugins) {
             foreach (json_decode($item->plugins) as $name => $value) {
                 $count = 1;
                 $values[str_replace($this->pluginName, '', $name, $count)] = $value;
             }
             $form->bind($values);
         }
         $fields = '';
         foreach ($form->getFieldset() as $field) {
             if (strpos($field->name, '[]') !== false) {
                 $search = 'name="' . $field->name . '"';
                 $replace = 'name="plugins[' . $this->pluginName . str_replace('[]', '', $field->name) . '][]"';
             } else {
                 $search = 'name="' . $field->name . '"';
                 $replace = 'name="plugins[' . $this->pluginName . $field->name . ']"';
             }
             $input = JString::str_ireplace($search, $replace, $field->__get('input'));
             $fields .= $field->__get('label') . ' ' . $input;
         }
         // Legacy code to maintain compatibillity with existing plugins that use params instead of JForm
         if (empty($fields) && K2_JVERSION == '25') {
             $form = new K2Parameter($item->plugins, $manifest, $this->pluginName);
             $fields = $form->render('plugins', $path);
         }
     }
     if ($fields) {
         $plugin = new stdClass();
         $plugin->name = $this->pluginNameHumanReadable;
         $plugin->fields = $fields;
         return $plugin;
     }
 }
Example #4
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $mainframe = JFactory::getApplication();
        $document = JFactory::getDocument();
        $js = "function jSelectProducts(id,title,object){\r\n\t\t\t\t\t\$('tiendaProductName').setProperty('value', title);\r\n\t\t\t\t\t\$('pluginstiendaproductID').setProperty('value', id);\r\n\t\t\t\t\t\$('tiendaAssign').setProperty('value', '1');\r\n\t\t\t\t\t\$('sbox-window').close();\r\n\t\t\t\t}";
        $document->addScriptDeclaration($js);
        $css = "#tiendaProductName {\r\n\t\t\t\t\tbackground: none repeat scroll 0% 0% rgb(255, 255, 255);\r\n\t\t\t\t\tfloat:left;\r\n\t\t\t\t\theight:18px;\r\n\t\t\t\t\tpadding-left:3px;\r\n\t\t\t\t}";
        $document->addStyleDeclaration($css);
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                $db = JFactory::getDBO();
                $query = "SELECT * FROM #__tienda_products WHERE product_id=" . (int) $productID;
                $db->setQuery($query);
                $product = $db->loadObject();
            }
        }
        if (!isset($product) || is_null($product)) {
            $product = new JObject();
            $product->product_name = '';
        }
        $output = '<div class="button2-left" style="margin-left:0; margin-right:10px;">
			<input type="text" disabled="disabled" value="' . $product->product_name . '" id="tiendaProductName"/>
			<div class="blank">
				<a href="index.php?option=com_tienda&amp;task=elementProduct&amp;tmpl=component" class="modal" rel="{handler: \'iframe\', size: {x: 800, y: 400}}" >' . JText::_('Assign product') . '</a>
			</div>
			<input type="hidden" value="" id="tiendaAssign" name="tiendaAssign"/>
		</div>
		<div class="clr"></div>
		<span class="k2Note">' . JText::_('Using this allows to assign a tienda product to a K2 item. Mind that this will override all the above settings!') . '</span>
		<br/>
		<div>
			<label for="tiendaUnassign">' . JText::_('Unassign product') . '</label> <input type="checkbox" value="1" id="tiendaUnassign" name="tiendaUnassign">
			<span class="k2Note">' . JText::_('Check this to remove any relation between this K2 item and tienda product') . '</span>
		</div>
		<br/>
		<div>
			<label for="tiendaRemove">' . JText::_('Remove product') . '</label> <input type="checkbox" value="1" id="tiendaRemove" name="tiendaRemove">
			<span class="k2Note">' . JText::_('This will delete the tienda product! Use with care!') . '</span>
		</div>
		';
        return $output;
    }
Example #5
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $mainframe = JFactory::getApplication();
     Tienda::load('TiendaSelect', 'library.select');
     $id = JRequest::getInt('cid');
     if ($id) {
         $K2Item = JTable::getInstance('K2Item', 'Table');
         $K2Item->load($id);
         $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
         $id = $params->get('productID');
         $db = JFactory::getDBO();
         $query = "SELECT manufacturer_id FROM #__tienda_products WHERE product_id=" . (int) $id;
         $db->setQuery($query);
         $manufacturer = $db->loadResult();
     }
     return TiendaSelect::manufacturer(@$manufacturer, 'plugins[tiendaproductManufacturer]', '', 'pluginstiendaproductManufacturer', false, true);
 }
Example #6
0
 function onRenderAdminForm(&$item, $type, $tab = '')
 {
     $mainframe =& JFactory::getApplication();
     $form = new K2Parameter($item->plugins, JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . $this->pluginName . '.xml', $this->pluginName);
     if (!empty($tab)) {
         $path = $type . '-' . $tab;
     } else {
         $path = $type;
     }
     $fields = $form->render('plugins', $path);
     if ($fields) {
         $plugin = new JObject();
         $plugin->set('name', $this->pluginNameHumanReadable);
         $plugin->set('fields', $fields);
         return $plugin;
     }
 }
Example #7
0
 function onRenderAdminForm(&$item, $type, $tab = '')
 {
     $mainframe = JFactory::getApplication();
     $manifest = K2_JVERSION == '15' ? JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . $this->pluginName . '.xml' : JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . $this->pluginName . DS . $this->pluginName . '.xml';
     if (!empty($tab)) {
         $path = $type . '-' . $tab;
     } else {
         $path = $type;
     }
     if (!isset($item->plugins)) {
         $item->plugins = NULL;
     }
     $form = new K2Parameter($item->plugins, $manifest, $this->pluginName);
     $fields = $form->render('plugins', $path);
     if ($fields) {
         $plugin = new stdClass();
         $plugin->name = $this->pluginNameHumanReadable;
         $plugin->fields = $fields;
         return $plugin;
     }
 }
Example #8
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $output = '
		<span class="k2Note">' . JText::_('Click apply to be able to create product quantities') . '</span>
		';
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                $db = JFactory::getDBO();
                $query = "SELECT SUM(quantity) FROM #__tienda_productquantities WHERE product_id =" . (int) $productID;
                $db->setQuery($query);
                $quantities = $db->loadResult();
                Tienda::load('TiendaUrl', 'library.url');
                $output = '<span>' . $quantities . '</span><div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setquantities&id=" . $productID . "&tmpl=component", JText::_('COM_TIENDA_SET_QUANTITIES')) . '</div>';
            }
        }
        return $output;
    }
Example #9
0
?>
				</td>
			</tr>
		</tfoot>
		<tbody>
			<?php 
$i = 0;
$pluginName = 'k2store';
$plugin = JPluginHelper::getPlugin('k2', $pluginName);
?>
			<?php 
foreach ($this->items as $product) {
    //legacy compatibility
    if (!isset($product->product_id)) {
        unset($plugins);
        $plugins = new K2Parameter($product->plugins, '', $pluginName);
        $product->item_enabled = $plugins->get('item_enabled');
        $product->item_sku = $plugins->get('item_sku');
        $product->item_price = $plugins->get('item_price');
        $product->special_price = $plugins->get('special_price');
        //check if we have them stored in the plugins field.
    }
    ?>

				<tr class="row<?php 
    echo $i % 2;
    ?>
">
					<td><?php 
    echo JHtml::_('grid.id', $i, $product->id);
    ?>
Example #10
0
 public static function getProduct($product_id)
 {
     if (!isset(self::$_product[$product_id])) {
         //first get the K2 item
         $item = K2StorePrices::_getK2Item($product_id);
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('*')->from('#__k2store_products')->where('product_id=' . $db->q($product_id));
         $db->setQuery($query);
         $product = $db->loadObject();
         $pluginName = 'k2store';
         //get the item price and tax profile id
         //$plugins = new JParameter($item->plugins, '', $pluginName);
         $plugin = JPluginHelper::getPlugin('k2', $pluginName);
         //		$pluginParams = new JParameter($plugin->params);
         if (JVERSION == 1.7) {
             // Get the output of the K2 plugin fields (the data entered by your site maintainers)
             $plugins = new JParameter($item->plugins, '', $pluginName);
         } else {
             $plugins = new K2Parameter($item->plugins, '', $pluginName);
         }
         if (!$product) {
             //legacy compatibility
             $product = new JObject();
             $product->item_enabled = $plugins->get('item_enabled');
             $product->item_sku = $plugins->get('item_sku');
             $product->item_price = $plugins->get('item_price');
             $product->special_price = $plugins->get('special_price');
             $product->item_tax_id = $plugins->get('item_tax');
             $product->item_shipping = $plugins->get('item_shipping');
             $product->item_qty = $plugins->get('item_qty');
             $product->item_cart_text = $plugins->get('item_cart_text');
         } else {
             $product->item_tax_id = $product->item_tax;
             $product->item_cart_text = $plugins->get('item_cart_text');
         }
         self::$_product[$product_id] = $product;
     }
     return self::$_product[$product_id];
 }
Example #11
0
 function onK2AfterDisplay(&$item, &$params, $limitstart)
 {
     $mainframe = JFactory::getApplication();
     if (!$this->_isInstalled() || $mainframe->isAdmin()) {
         return null;
     }
     if ($this->params->get('categories')) {
         $categories = (array) $this->params->get('categories');
         if (!in_array($item->catid, $categories)) {
             return;
         }
     }
     $tiendaParams = new K2Parameter($item->plugins, '', $this->_name);
     $productID = $tiendaParams->get('productID', NULL);
     if (is_null($productID)) {
         return null;
     }
     $model = new TiendaModelProducts();
     $model->setId((int) $productID);
     $product = $model->getItem();
     if (is_null($product)) {
         return null;
     }
     if (!$product->product_enabled) {
         return null;
     }
     JHTML::_('stylesheet', 'menu.css', 'media/com_tienda/css/');
     JHTML::_('stylesheet', 'tienda.css', 'media/com_tienda/css/');
     JHTML::_('script', 'tienda.js', 'media/com_tienda/js/');
     ob_start();
     include JPATH_SITE . '/plugins/k2/tienda/tmpl/quickadd.php';
     $contents = ob_get_clean();
     return $contents;
 }
Example #12
0
 function onRenderAdminForm(&$item, $type, $tab = '')
 {
     $app = JFactory::getApplication();
     if ($type == 'item' && $tab == 'content') {
         if (!$app->isSite()) {
             //render the form
             if (!empty($tab)) {
                 $path = $type . '-' . $tab;
             } else {
                 $path = $type;
             }
             if (!isset($item->plugins)) {
                 $item->plugins = NULL;
             }
             $xml_file = JPATH_SITE . '/plugins/k2/' . $this->pluginName . '/' . $this->pluginName . '.xml';
             if (version_compare(JVERSION, '3.0', 'ge')) {
                 jimport('joomla.form.form');
                 $form = JForm::getInstance('plg_k2_' . $this->pluginName . '_' . $path, $xml_file, array(), true, 'fields[@group="' . $path . '"]');
                 //print_r($form);
                 $values = array();
                 if ($item->plugins) {
                     foreach (json_decode($item->plugins) as $name => $value) {
                         $count = 1;
                         $values[str_replace($this->pluginName, '', $name, $count)] = $value;
                     }
                     $form->bind($values);
                 }
                 $fields = '';
                 foreach ($form->getFieldset() as $field) {
                     $search = 'name="' . $field->name . '"';
                     $replace = 'name="plugins[' . $this->pluginName . $field->name . ']"';
                     $input = JString::str_ireplace($search, $replace, $field->__get('input'));
                     $fields .= $field->__get('label') . ' ' . $input;
                 }
             } else {
                 $form = new K2Parameter($item->plugins, $xml_file, $this->pluginName);
                 $fields = $form->render('plugins', $path);
             }
             if ($fields) {
                 $plugin = new JObject();
                 $plugin->set('name', JText::_('K2Store'));
                 $plugin->set('fields', $fields);
                 return $plugin;
             }
         }
     }
 }
Example #13
0
    function onK2AfterDisplayContent(&$item, &$params, $limitstart)
    {
        if (JRequest::getVar('view') !== "item") {
            //display only in item view
            return '';
        }
        //Getting Item params
        $plugins = new K2Parameter($item->plugins, '', $this->pluginName);
        $lat = trim($plugins->get('latitude'));
        $lon = trim($plugins->get('longitude'));
        if (empty($lat) || empty($lon)) {
            return false;
        }
        //loading defaults
        $defLocal = $this->params->get('local');
        $defMarker = $this->params->get('cmarker');
        $apiKey = $this->params->get('apikey');
        $sync = $this->params->get('async');
        $defHeight = $this->params->get('height');
        //loading article params
        $itemLocal = $plugins->get('local');
        $itemMapType = $plugins->get('maptype');
        $itemMarker = $plugins->get('cmarker');
        $itemHeight = $plugins->get('height');
        $itemInfo = $plugins->get('infowindow');
        $deflocal = empty($loadDefLocal) ? '' : '&language=' . $this->params->get('local');
        $defcmarker = empty($defMarker) ? '' : ',icon: "' . $this->params->get('cmarker') . '"';
        $apikey = empty($apiKey) ? '' : '&key=' . $this->params->get('apikey');
        $async = empty($sync) ? FALSE : TRUE;
        $zoom = $plugins->get('zoom') == '-1' ? $this->params->get('zoom') : $plugins->get('zoom');
        $mapMaxZoom = $plugins->get('maxzoom') == '-1' ? $this->params->get('maxzoom') : $plugins->get('maxzoom');
        $mapMinZoom = $plugins->get('minzoom') == '-1' ? $this->params->get('minzoom') : $plugins->get('minzoom');
        $local = empty($itemLocal) ? $deflocal : '&language=' . $itemLocal;
        $maptype = $itemMapType === "0" ? $this->params->get('maptype') : $itemMapType;
        $cmarker = empty($itemMarker) ? $defcmarker : ',icon: "' . JURI::base() . $itemMarker . '"';
        $height = empty($itemHeight) ? $defHeight : $itemHeight;
        $infowindow = empty($itemInfo) ? "" : '
			var infowindow = new google.maps.InfoWindow({
				maxWidth: 500,
				content:\'' . trim(addslashes(preg_replace('/\\s\\s+/', ' ', $itemInfo))) . '\'
			});
			google.maps.event.addListener(marker, \'click\', openmarker);
			function openmarker() {infowindow.open(map, marker);}
			openmarker();';
        $mapsOptions = "\n\t\tvar mapOptions = {\n  \t\t\tzoom: " . $zoom . ",\n    \t\tcenter: new google.maps.LatLng(" . $lat . ", " . $lon . "),\n    \t\tmapTypeId: google.maps.MapTypeId." . $maptype . ",\n    \t\tmaxZoom:" . $mapMaxZoom . ",\n    \t\tminZoom:" . $mapMinZoom . "    \t\t\n  \t\t};";
        $document = JFactory::getDocument();
        if (!$async) {
            $document->addScript('https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false' . $local . $apikey);
            $document->addScriptDeclaration("\n\t\tvar map;\n\t\tfunction initialize() {\n\t\t\t" . $mapsOptions . "  \n\t\t\tmap = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);\n\t\t\tvar marker = new google.maps.Marker({\n\t\t\t\tmap: map,\n\t\t\t\tposition: map.getCenter()" . $cmarker . "\n\t\t\t});\n\t\t" . $infowindow . "\n\t\t}\n\t\tgoogle.maps.event.addDomListener(window, 'load', initialize);");
        } else {
            $document->addScriptDeclaration("\n\t\tfunction initialize() {\n\t\t\t" . $mapsOptions . "  \n\t\t\tvar map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);\n\t\t\tvar marker = new google.maps.Marker({\n\t\t\t\tmap: map,\n\t\t\t\tposition: map.getCenter()" . $cmarker . "\n\t\t\t});\n\t\t" . $infowindow . "      \n\t\t}\n\t\tfunction loadScript() {\n \t\t\tvar script = document.createElement('script');\n\t\t\tscript.type = 'text/javascript';\n\t\t\tscript.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initialize" . $local . $apikey . "';\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t\twindow.onload = loadScript;");
        }
        $output = '<div id="map-canvas"></div>';
        // Add styles
        $style = '#map-canvas img{max-width:none;}#map-canvas {height:' . $height . 'px;margin: 0px;padding: 0px; }';
        $document->addStyleDeclaration($style);
        return $output;
    }