Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/css/ |
| [Home] [System Details] [Kill Me] |
PK[��[�)`� .DS_Storenu�[���Bud1 dfbwspblobdompdfbwspblob�bplist00�
]ShowStatusBar[ShowSidebar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds[ShowPathbar _{{737,
381}, {1461, 797}} %1=I`myz{|}~��dompdfvSrnlong
@� @� @� @E DSDB
`� @� @�
@PK[��[{��!����helpers.phpnu�[���<?php
/*------------------------------------------------------------------------
# com_invoices - Invoice Manager for Joomla
# ------------------------------------------------------------------------
# author Germinal Camps
# copyright Copyright (C) 2012 - 2016 JoomlaThat.com. All Rights
Reserved.
# @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.joomlathat.com
# Technical Support: Forum - http://www.joomlathat.com/support
-------------------------------------------------------------------------*/
//no direct access
defined('_JEXEC') or die('Restricted access.');
class InvoicesHelper{
static function showInvoicesFooter(){
require_once(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'version.php');
return InvoicesVersion::show_footer();
}
static function format($number, $currency = false){
$params = JComponentHelper::getParams( 'com_invoices' );
$db = JFactory::getDBO();
if(is_int($currency)){
$query = "SELECT * FROM #__invoices_currencies WHERE id =
".(int)$currency;
$db->setQuery($query);
$currency = $db->loadObject();
}
if(!$currency){
$query = "SELECT * FROM #__invoices_currencies WHERE id =
".(int)$params->get('currency_id', 1);
$db->setQuery($query);
$currency = $db->loadObject();
}
if($currency == 'percent'){
$currency = new stdClass();
$currency->decpoint = ".";
$currency->thousands = ",";
$currency->decimals = 0;
$currency->symbol_before = "";
$currency->symbol_after = "%";
}
$decpoint = $currency->decpoint;
$thousands = $currency->thousands;
$decimals = $currency->decimals;
$before = $currency->symbol_before;
$after = $currency->symbol_after;
return $before . number_format($number, $decimals, $decpoint,
$thousands) . $after ;
}
static function format_editing($number){
$params = JComponentHelper::getParams( 'com_invoices' );
$decimals = $params->get('decimals_editing', 2);
return number_format($number, $decimals, '.', '') ;
}
static function format_simple($number){
return str_replace(".", ",", $number) ;
}
static function get_subtotal($invoice_id){
$db = JFactory::getDBO();
$query = ' SELECT SUM((it.value * it.amount -
it.discount)*(1+it.tax/100)) FROM #__invoices_items AS it WHERE
it.invoice_id = '.$invoice_id ;
$db->setQuery($query);
$subtotal = $db->loadResult();
$query = ' SELECT discount FROM #__invoices_invoices AS i WHERE i.id
= '.$invoice_id ;
$db->setQuery($query);
$discount = $db->loadResult();
return $subtotal - $discount;
}
static function get_subtotal_items($invoice_id){
$db = JFactory::getDBO();
$query = ' SELECT SUM(it.value * it.amount - it.discount) FROM
#__invoices_items AS it WHERE it.invoice_id = '.$invoice_id ;
$db->setQuery($query);
$subtotal = $db->loadResult();
$query = ' SELECT discount FROM #__invoices_invoices AS i WHERE i.id
= '.$invoice_id ;
$db->setQuery($query);
$discount = $db->loadResult();
return $subtotal - $discount;
}
static function get_total($invoice, $update_taxes = false){
$db = JFactory::getDBO();
$taxes_value = 0;
$thetaxvalue = 0 ;
if(!isset($invoice->subtotal_items)) $invoice->subtotal_items =
InvoicesHelper::get_subtotal_items($invoice->id);
$subtotal1 = $invoice->subtotal ;
$subtotal1_items = $invoice->subtotal_items ;
//if($invoice->taxes){
$query = ' SELECT tax.*, tai.value AS value, tai.id AS tai_id FROM
#__invoices_taxes AS tax '
.' LEFT JOIN #__invoices_tax_invoice AS tai ON (tai.tax_id = tax.id
AND tai.reference_id = ' . $invoice->id . ' AND tai.type = 1)
'
.' WHERE tai.active = 1 '
.' ORDER BY ordering, name ' ;
$db->setQuery($query);
$taxes = $db->loadObjectList();
foreach($taxes as $tax){
switch($tax->type){
case "percent":
if($tax->ordering == 1){ //first group of taxes
if($tax->calculate_on == 1){
$thetaxvalue = ( $tax->value / 100 ) * $invoice->subtotal_items
;
$taxes_value += ( $tax->value / 100 ) *
$invoice->subtotal_items ;
}
else{
$thetaxvalue = ( $tax->value / 100 ) * $invoice->subtotal ;
$taxes_value += ( $tax->value / 100 ) * $invoice->subtotal ;
}
}
else if($tax->ordering == 2){ //second group of taxes
if($tax->calculate_on == 1){
$thetaxvalue = ( $tax->value / 100 ) * $subtotal1_items ;
$taxes_value += ( $tax->value / 100 ) * $subtotal1_items ;
}
else{
$thetaxvalue = ( $tax->value / 100 ) * $subtotal1 ;
$taxes_value += ( $tax->value / 100 ) * $subtotal1 ;
}
}
break;
case "static":
$thetaxvalue = $tax->value ;
$taxes_value += $tax->value ;
break;
}
if($tax->ordering == 1){
$subtotal1 += $thetaxvalue ;
$subtotal1_items += $thetaxvalue ;
}
if($update_taxes){
$query = "UPDATE #__invoices_tax_invoice SET computed_value =
'$thetaxvalue' WHERE id = " . $tax->tai_id ;
$db->setQuery($query);
$db->query();
}
}
//}
$total = $invoice->subtotal + $taxes_value ;
return $total;
}
static function get_display_taxes($row){
$db = JFactory::getDBO();
$subtotal = $row->subtotal;
$subtotal_items = $row->subtotal_items;
$subtotal1 = $row->subtotal ;
$subtotal1_items = $row->subtotal_items ;
$display_taxes = array();
//taxes in 2.1
//individual item taxes
$query = ' SELECT SUM((it.value * it.amount -
it.discount)*(it.tax/100)) AS tax_value, it.tax_id '
.' FROM #__invoices_items AS it '
.' WHERE it.invoice_id = '.$row->id
.' GROUP BY it.tax_id' ;
$db->setQuery($query);
$items_taxes = $db->loadObjectList('tax_id');
//invoice-global taxes
$query = ' SELECT tax.*, tai.value AS value, tai.active FROM
#__invoices_taxes AS tax '
.' LEFT JOIN #__invoices_tax_invoice AS tai ON (tai.tax_id = tax.id
AND tai.reference_id = ' . $row->id . ' AND tai.type = 1 AND
tai.active = 1) '
.' ORDER BY ordering, name ' ;
$db->setQuery($query);
$taxes = $db->loadObjectList('id');
foreach($taxes as $tax){
$taxes_value = 0 ;
//invoice-global taxes
if($tax->active){
switch($tax->type){
case "percent":
if($tax->ordering == 1){ //first group of taxes
if($tax->calculate_on == 1) $taxes_value = ( $tax->value / 100
) * $subtotal_items ;
else $taxes_value = ( $tax->value / 100 ) * $subtotal ;
}
else if($tax->ordering == 2){ //second group of taxes
if($tax->calculate_on == 1) $taxes_value = ( $tax->value / 100
) * $subtotal1_items ;
else $taxes_value = ( $tax->value / 100 ) * $subtotal1 ;
}
break;
case "static":
$taxes_value = $tax->value ;
break;
}
if($tax->ordering == 1){
$subtotal1 += $taxes_value ;
$subtotal1_items += $taxes_value ;
}
}
$taxobject = new stdClass();
$taxobject->tax_id = $tax->id;
//individual item taxes
if(isset($items_taxes[$tax->id])) $taxobject->items_tax =
$items_taxes[$tax->id] ;
else {
$taxobject->items_tax = new stdClass();
$taxobject->items_tax->tax_value = 0 ;
//if only global tax, we can show the percentage
if($tax->active && $tax->type == "percent")
$taxobject->tax_percentage = InvoicesHelper::format($tax->value,
'percent');
}
$taxobject->global_tax = $taxes_value;
$taxobject->tax = $taxobject->items_tax->tax_value +
$taxobject->global_tax;
$taxobject->formatted_tax =
InvoicesHelper::format($taxobject->tax, $row->currency_id);
$display_taxes[$tax->id] = $taxobject ;
}
return $display_taxes;
}
static function get_total_from_id($invoice_id , $update_taxes = false){
$total = 0;
if($invoice_id){
$db = JFactory::getDBO();
$query = ' SELECT * FROM #__invoices_invoices WHERE id = ' .
$invoice_id ;
$db->setQuery($query);
$invoice = $db->loadObject();
if($invoice->id){
$invoice->subtotal = InvoicesHelper::get_subtotal($invoice_id);
$total = InvoicesHelper::get_total($invoice, $update_taxes);
}
}
return $total;
}
static function download_pdf_button($id){
$version = PHP_VERSION >= 5.0 ? true : false ;
$quotes = get_magic_quotes_gpc();
if(file_exists(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'dompdf'.DS.'autoload.inc.php')
&& $version && !$quotes){
$mainframe = JFactory::getApplication();
$uri = JFactory::getURI();
if(!$mainframe->isSite()){
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&cid[]='.$id);
}
else $url =
JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&id='.$id);
$return = "<a href='".$url."'
title=\"".JText::_('DOWNLOAD_INVOICE_PDF')."\">".JHTML::image('components/com_invoices/assets/images/page_white_acrobat.png',
JText::_('DOWNLOAD_INVOICE_PDF'))."</a>" ;
}
else $return = "";
return $return ;
}
static function download_pdf_link($id){
$version = PHP_VERSION >= 5.0 ? true : false ;
$quotes = get_magic_quotes_gpc();
if(file_exists(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'dompdf'.DS.'autoload.inc.php')
&& $version && !$quotes){
$mainframe = JFactory::getApplication();
$uri = JFactory::getURI();
if(!$mainframe->isSite()){
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&cid[]='.$id,
false);
}
else $url =
JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&id='.$id);
$return = $url;
}
else $return = "";
return $return ;
}
static function pdf_enabled(){
$version = PHP_VERSION >= 5.0 ? true : false ;
$quotes = get_magic_quotes_gpc();
if(file_exists(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'dompdf'.DS.'autoload.inc.php')
&& $version && !$quotes){
return true;
}
else return false;
}
static function view_modal_button($id){
$modal = true ;
if($modal){
$link = "&tmpl=component" ;
$rel = 'rel="{ size: {x: 800, y: 500}, handler:
\'iframe\'}"';
}
$mainframe = JFactory::getApplication();
$uri = JFactory::getURI();
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&id='.$id.$link);
if(!$mainframe->isSite()){
//$url =
$uri->root().'index.php?option=com_invoices&view=invoice&id='.$id.$link;
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&cid[]='.$id.$link);
}
$return = "<a class='modal' ".$rel."
href='".$url."'
title=\"".JText::_('VIEW_INVOICE_DETAILS')."\">".JHTML::image('components/com_invoices/assets/images/magnifier.png',
JText::_('VIEW_INVOICE_DETAILS'))."</a>" ;
return $return ;
}
static function view_online_button($id){
$mainframe = JFactory::getApplication();
$uri = JFactory::getURI();
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&id='.$id
);
if(!$mainframe->isSite()){
//$url =
$uri->root().'index.php?option=com_invoices&view=invoice&id='.$id.'&tmpl=component';
$url =
JRoute::_('index.php?option=com_invoices&view=invoice&cid[]='.$id.'&tmpl=component');
}
$return = "<a target='_blank'
href='".$url."'
title=\"".JText::_('VIEW_INVOICE_ONLINE')."\">".JHTML::image('components/com_invoices/assets/images/invoice.png',
JText::_('VIEW_INVOICE_ONLINE'))."</a>" ;
return $return ;
}
static function send_email_button($id, $type = "invoice"){
$mainframe = JFactory::getApplication();
if(!$mainframe->isSite()){
$url =
JRoute::_('index.php?option=com_invoices&controller='.$type.'&task=send_email&cid[]='.$id);
}
else{
$url =
JRoute::_('index.php?option=com_invoices&task=send&id='.$id);
}
$return = "<a href='".$url."'
title=\"".JText::_('SEND_EMAIL')."\">".JHTML::image('components/com_invoices/assets/images/email.png',
JText::_('SEND_EMAIL'))."</a>" ;
return $return ;
}
static function send_email_link($id, $type = "invoice"){
$mainframe = JFactory::getApplication();
if(!$mainframe->isSite()){
$url =
JRoute::_('index.php?option=com_invoices&controller='.$type.'&task=send_email&cid[]='.$id,
false);
}
else{
$url =
JRoute::_('index.php?option=com_invoices&task=send&id='.$id);
}
return $url ;
}
static function create_invoice($data, $items, $payments){
$mainframe = JFactory::getApplication();
$model = InvoicesHelper::getInvoiceAdminModel();
require_once(
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'tables'.DS.'invoice.php'
);
require_once(
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'tables'.DS.'contact.php'
);
require_once(
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'tables'.DS.'item.php'
);
require_once(
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'tables'.DS.'payment.php'
);
require_once(
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'tables'.DS.'taxinvoice.php'
);
if ($invoice_id = $model->store($data, $items, $payments)) {
$msg = JText::_( 'INVOICE_SAVED' );
$type = "message" ;
} else {
$msg = JText::_( 'ERROR_SAVING_INVOICE' );
$type = "error" ;
}
return $invoice_id;
}
static function getInvoiceAdminModel()
{
if (!class_exists( 'InvoicesModelInvoice' ))
{
// Build the path to the model based upon a supplied base path
$path =
JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_invoices'.DS.'models'.DS.'invoice.php';
$false = false;
// If the model file exists include it and try to instantiate the object
if (file_exists( $path )) {
require_once( $path );
if (!class_exists( 'InvoicesModelInvoice' )) {
JError::raiseWarning( 0, 'View class InvoicesModelInvoice not
found in file.' );
return $false;
}
} else {
JError::raiseWarning( 0, 'View InvoicesModelInvoice not supported.
File not found.' );
return $false;
}
}
$model = new InvoicesModelInvoice();
return $model;
}
static function getStatus(){
$status = array();
$status[] = "paid";
$status[] = "pending";
$status[] = "partial_paid";
$status[] = "pastdue";
$status[] = "refunded";
$status[] = "partial_refunded";
$status[] = "corrected";
return $status;
}
static function getQuoteStatus(){
$status = array();
$status[] = "pending";
$status[] = "accepted";
$status[] = "accepted_client";
$status[] = "cancelled";
$status[] = "rejected";
$status[] = "rejected_client";
$status[] = "expired";
return $status;
}
static function getStatusPaymentFilters(){
$status = array();
$status[] = (object)array("id" => "unpaid",
"name" => 'UNPAID_SIMPLE');
$status[] = (object)array("id" => "paid",
"name" => 'PAID');
$status[] = (object)array("id" => "pending",
"name" => 'PENDING_VALIDATION');
return $status;
}
static function getPaymentStatus(){
$status = array();
$status[0] = JText::_('UNPAID');
$status[1] = JText::_('PAID');
$status[2] = JText::_('UNPAID_ONTIME');
$status[3] = JText::_('PENDING_VALIDATION');
return $status;
}
static function getPaymentData($payment_id){
$db = JFactory::getDBO();
$query = ' SELECT pa.* FROM #__invoices_payments AS pa WHERE pa.id =
'.$payment_id;
$db->setQuery($query);
$payment = $db->loadObject();
return $payment;
}
static function getNextRecurrencyDate($invoice){
if($invoice["rec_year"]) $months =
$invoice["rec_year"] * 12 + $invoice["rec_month"] ;
else $months = $invoice["rec_month"] ;
$thetime = $invoice["rec_nextdate"] . " +
".$months." months + ".$invoice["rec_day"]."
days" ;
//echo $thetime;die;
$nextdate = strtotime($thetime) ;
$nextdate = date("Y-m-d", $nextdate) ;
return $nextdate ;
}
static function getPaymentLink($payment_id){
$uri = JFactory::getURI();
$link = $uri->base() .
'index.php?option=com_invoices&view=payment&id='.$payment_id
;
$link = str_replace("administrator/","",$link) ;
return $link;
}
static function getInvoiceLink($invoice_id){
$uri = JFactory::getURI();
$link = $uri->base() .
'index.php?option=com_invoices&view=invoice&id='.$invoice_id
;
$link = str_replace("administrator/","",$link) ;
return $link;
}
static function getInvoicePublicLink($invoice_id){
$uri = JFactory::getURI();
$db = JFactory::getDBO();
$query = " SELECT auth_code FROM #__invoices_invoices WHERE id =
".$invoice_id ;
$db->setQuery($query);
$auth_code = $db->loadResult();
$link = $uri->base() .
'index.php?option=com_invoices&view=invoice&id='.$invoice_id
.'&auth_code='.$auth_code;
$link = str_replace("administrator/","",$link) ;
return $link;
}
static function getQuoteAcceptLink($quote_id){
$uri = JFactory::getURI();
$db = JFactory::getDBO();
$query = " SELECT auth_code FROM #__invoices_invoices WHERE id =
".$quote_id ;
$db->setQuery($query);
$auth_code = $db->loadResult();
$link = $uri->base() .
'index.php?option=com_invoices&task=accept_quote&id='.$quote_id
.'&auth_code='.$auth_code;
$link = str_replace("administrator/","",$link) ;
return $link;
}
static function getQuoteRejectLink($quote_id){
$uri = JFactory::getURI();
$db = JFactory::getDBO();
$query = " SELECT auth_code FROM #__invoices_invoices WHERE id =
".$quote_id ;
$db->setQuery($query);
$auth_code = $db->loadResult();
$link = $uri->base() .
'index.php?option=com_invoices&task=reject_quote&id='.$quote_id
.'&auth_code='.$auth_code;
$link = str_replace("administrator/","",$link) ;
return $link;
}
static function getInvoiceNum($real_invoice_num, $type = 1){
$params = JComponentHelper::getParams( 'com_invoices' );
if($type == 1) $format = $params->get('invoice_num_format')
;
elseif($type == 2) $format =
$params->get('quote_num_format') ;
$real_invoice_num = str_pad($real_invoice_num,
$params->get('invoice_number_digits', 0), '0',
STR_PAD_LEFT);
$string = str_replace("[num]", $real_invoice_num, $format) ;
$string = str_replace("[yyyy]", date("Y"), $string) ;
$string = str_replace("[mm]", date("m"), $string) ;
$string = str_replace("[dd]", date("d"), $string) ;
return $string ;
}
static function getInvoiceStatus($invoice, $total, $total_payments,
$amount_outstanding){
$params = JComponentHelper::getParams( 'com_invoices' );
$status = $invoice->status ;
if(!$status && $params->get('computestatus')
&& $invoice->type == 1){
//if the status is not set, we calculate it
$status = InvoicesHelper::getComputedInvoiceStatus($invoice, $total,
$total_payments, $amount_outstanding);
//$status = $invoice->computed_status;
}
return $status;
}
static function getComputedInvoiceStatus($invoice, $total, $total_payments
= false, $amount_outstanding = false){
$db = JFactory::getDBO();
$params = JComponentHelper::getParams( 'com_invoices' );
if(!$total_payments){
$query = " SELECT SUM(payment_amount) FROM #__invoices_payments
WHERE payment_status = 1 AND invoice_id = ".$invoice->id ;
$db->setQuery($query);
$total_payments = $db->loadResult();
}
if(!$amount_outstanding){
$query = " SELECT SUM(payment_amount) FROM #__invoices_payments
WHERE payment_status = 0 AND invoice_id = ".$invoice->id ;
$db->setQuery($query);
$amount_outstanding = $db->loadResult();
}
$total_payments = round($total_payments,
$params->get('decimals', 2));
$total = round($total, $params->get('decimals', 2));
if($amount_outstanding == 0 && $total_payments >= $total){
$status = "paid"; //paid in full
}
elseif($invoice->invoice_duedate != "0000-00-00" &&
$invoice->invoice_duedate != "0000-00-00 00:00:00" &&
$invoice->invoice_duedate != "" ){
if(strtotime($invoice->invoice_duedate) <= time()) {
$status = "pastdue"; //past due date
}
else {
if($amount_outstanding && $total_payments){
$status = "partial_paid"; //partially paid
}
else $status = "pending"; //pending
}
}
elseif($invoice->invoice_duedate == "0000-00-00" ||
$invoice->invoice_duedate == "0000-00-00 00:00:00" ||
!$invoice->invoice_duedate){
if($amount_outstanding && $total_payments){
$status = "partial_paid"; //partially paid
}
elseif($total_payments){
$status = "partial_paid"; //partially paid
}
else $status = "pending"; //pending
}
return $status;
}
static function updateComputedStatus($invoice_id, $calculate_total =
false, $create_auth_code = false){
$db = JFactory::getDBO();
$query = " SELECT * FROM #__invoices_invoices WHERE id =
".$invoice_id ;
$db->setQuery($query);
$invoice = $db->loadObject();
$sql_total = "";
$sql_auth_code = "";
if($calculate_total) {
$computed_total = InvoicesHelper::get_total_from_id($invoice->id) ;
$computed_subtotal = InvoicesHelper::get_subtotal_items($invoice->id)
;
$sql_total = ', computed_total = '.$computed_total.',
computed_subtotal = '.$computed_subtotal ;
}
else $computed_total = $invoice->computed_total ;
if(!$invoice->auth_code) {
$auth_code = InvoicesHelper::genRandomCode() ;
$sql_auth_code = ', auth_code =
"'.$auth_code.'" ' ;
}
else $sql_auth_code = "" ;
$computed_status = InvoicesHelper::getComputedInvoiceStatus($invoice,
$computed_total) ;
$query = ' UPDATE #__invoices_invoices SET '.
' computed_status = "'.$computed_status.'"
'.
$sql_total .
$sql_auth_code .
' WHERE id = '.$invoice_id .
' LIMIT 1 ';
$db->setQuery($query);
$db->query();
//added 2.1
InvoicesHelper::updateComputedData($invoice_id);
}
static function updateComputedData($invoice_id){
$db = JFactory::getDBO();
$query = " SELECT * FROM #__invoices_invoices WHERE id =
".$invoice_id ;
$db->setQuery($query);
$row = $db->loadObject();
$computed_total = InvoicesHelper::get_total_from_id($invoice_id, true) ;
$computed_subtotal = InvoicesHelper::get_subtotal_items($invoice_id);
$computed = new StdClass();
$computed->total = $computed_total;
$computed->subtotal = InvoicesHelper::get_subtotal($invoice_id);
$computed->subtotal_items = $computed_subtotal;
$query = ' SELECT SUM(pa.payment_amount) AS total_paid,
COUNT(DISTINCT pa.id) AS paid_payments FROM #__invoices_payments AS pa
WHERE pa.invoice_id = '.$invoice_id.' AND pa.payment_status = 1
' ;
$db->setQuery($query);
$computed->total_paid = $db->loadObject();
$query = ' SELECT SUM(pa.payment_amount) AS total_unpaid,
COUNT(DISTINCT pa.id) AS unpaid_payments FROM #__invoices_payments AS pa
WHERE pa.invoice_id = '.$invoice_id.' AND pa.payment_status = 0
' ;
$db->setQuery($query);
$computed->total_unpaid = $db->loadObject();
$row->subtotal = $computed->subtotal;
$row->subtotal_items = $computed_subtotal;
//store taxes in json
$computed->taxes = InvoicesHelper::get_display_taxes($row);
$computed = json_encode($computed);
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('computed') . ' = ' .
$db->quote($computed),
$db->quoteName('computed_subtotal') . ' = ' .
$db->quote($computed_subtotal)
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = '.$invoice_id
);
$query->update($db->quoteName('#__invoices_invoices'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
static function render_status($status){
switch($status){
case "paid": case "payed": case
"accepted": case "accepted_client":
$status = "<span class='label
label-success'>".JText::_($status)."</span>" ;
break;
case "pending":case "partial_paid":
$status = "<span class='label
label-warning'>".JText::_($status)."</span>" ;
break;
case "pastdue": case "rejected": case
"rejected_client":
$status = "<span class='label
label-important'>".JText::_($status)."</span>"
;
break;
case "refunded": case "partial_refunded": case
"cancelled": case "expired":
$status = "<span class='label
label-inverse'>".JText::_($status)."</span>" ;
break;
case "corrected":
$status = "<span class='label
label-info'>".JText::_($status)."</span>" ;
break;
default:
$status = "<span class='label
label-default'>".JText::_("NOT_SETTED")."</span>"
;
break;
}
return $status;
}
static function render_status_class($status){
switch($status){
case "paid": case "payed": case
"accepted": case "accepted_client":
$status = "success" ;
break;
case "pending":case "partial_paid":
$status = "warning" ;
break;
case "pastdue": case "rejected": case
"rejected_client":
$status = "danger" ;
break;
case "refunded": case "partial_refunded": case
"cancelled": case "expired":
$status = "inverse" ;
break;
case "corrected":
$status = "info" ;
break;
default:
$status = "default" ;
break;
}
return $status;
}
static function getThePaymentStatus($payment){
if($payment->payment_status){
$thestatus = 1;
}
elseif($payment->payment_duedate != "0000-00-00 00:00:00"
&& !$payment->payment_status){
if(strtotime($payment->payment_duedate) <= time()) {
$thestatus = 0;
}
else {
$thestatus = 2;
}
}
elseif($payment->payment_duedate == "0000-00-00 00:00:00"){
$thestatus = 2;
}
if($payment->payment_status == 2){
$thestatus = 3;
}
return $thestatus ;
}
static function render_status_payment($status){
$payment_status = InvoicesHelper::getPaymentStatus();
switch($status){
case 0:
$status = "<span class='label
label-important'>".$payment_status[$status]."</span>"
;
break;
case 1:
$status = "<span class='label
label-success'>".$payment_status[$status]."</span>"
;
break;
case 2:
$status = "<span class='label
label-warning'>".$payment_status[$status]."</span>"
;
break;
case 3:
$status = "<span class='label
label-default'>".$payment_status[$status]."</span>"
;
break;
}
return $status;
}
static function render_num_payments_received($num){
switch($num){
case 0:
$status = "<span class='badge badge-default
badge-secondary'>".$num."</span>" ;
break;
default:
$status = "<span class='badge
badge-success'>".$num."</span>" ;
break;
}
return $status;
}
static function render_num_pending_payments($num){
switch($num){
case 0:
$status = "<span
class='badge'>".$num."</span>" ;
break;
default:
$status = "<span class='badge
badge-warning'>".$num."</span>" ;
break;
}
return $status;
}
static function PDFavailable(){
return InvoicesHelper::pdf_enabled();
}
static function genRandomCode($length = 64)
{
$salt =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$base = strlen($salt);
$makepass = '';
/*
* Start with a cryptographic strength random string, then convert it to
* a string with the numeric base of the salt.
* Shift the base conversion on each character so the character
* distribution is even, and randomize the start shift so it's not
* predictable.
*/
$random = JCrypt::genRandomBytes($length + 1);
$shift = ord($random[0]);
for ($i = 1; $i <= $length; ++$i)
{
$makepass .= $salt[($shift + ord($random[$i])) % $base];
$shift += ord($random[$i]);
}
return $makepass;
}
static function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
static function replace_string_between($string, $start, $end, $replace){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return $string;
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr_replace($string,$replace,$ini,$len);
}
static function updateSentDate($id){
$db = JFactory::getDBO();
$query = " UPDATE #__invoices_invoices SET `last_sent` = NOW() WHERE
id = ".$id;
$db->setQuery($query);
$db->query();
}
static function allowEdit($recordId = 0, $ownerId = 0)
{
if(!$recordId){
$array = JRequest::getVar('cid', 0, '',
'array');
$recordId = (int)$array[0];
}
$user = JFactory::getUser();
//new item
if(!$recordId){
if ($user->authorise('core.create',
'com_invoices' ))
{
return true;
}
else return false;
}
// Check general edit permission first.
if ($user->authorise('core.edit', 'com_invoices'
))
{
return true;
}
// Fallback on edit.own.
// First test if the permission is available.
if ($user->authorise('core.edit.own',
'com_invoices' ))
{
// Now test the owner is the user.
if(!$ownerId){
$db = JFactory::getDBO();
$query = ' SELECT created_by FROM #__invoices_invoices WHERE id =
'.$recordId;
$db->setQuery($query);
$ownerId = $db->loadResult();
}
if (empty($ownerId) && $recordId)
{
return false;
}
// If the owner matches 'me' then do the test.
if ($ownerId == $user->id)
{
return true;
}
}
return false;
}
static function canDelete($recordId = 0, $ownerId = 0)
{
$user = JFactory::getUser();
return $user->authorise('core.delete',
'com_invoices');
}
static function canEditState($recordId = 0, $ownerId = 0)
{
$user = JFactory::getUser();
return $user->authorise('core.edit.state',
'com_invoices');
}
static function versionBox()
{
$db = JFactory::getDBO();
$query = ' SELECT manifest_cache FROM #__extensions WHERE element =
"com_invoices" AND type = "component" ';
$db->setQuery( $query );
$extenison_info = $db->loadObject();
$extenison_info = json_decode($extenison_info->manifest_cache);
$installed_version = $extenison_info->version;
$versionBox = '';
$versionBox .= "<div class='row-fluid version-box
hidden-xs'><div class=''><div
class='container-fluid'><div class='row-fluid
sys-info-title'><span>".JText::_('SYSTEM_INFO')."</span></div><div
class='row-fluid'><span>".JText::sprintf('INSTALLED_VERSION',
$installed_version)."</span></div><div
class='row-fluid'><span>".JText::_('LATEST_VERSION')."</span><span
id='latest-version'>".$installed_version."</span></div><div
class='row-fluid'><div
id='update-info'>".JText::_('SEARCHING_UPDATES')."</div></div></div></div></div>";
return $versionBox;
}
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('INVOICES'),
'index.php?option=com_invoices',
$vName == 'invoices'
);
JHtmlSidebar::addEntry(
JText::_('QUOTES'),
'index.php?option=com_invoices&controller=quotes',
$vName == 'quotes'
);
JHtmlSidebar::addEntry(
JText::_('PAYMENTS'),
'index.php?option=com_invoices&controller=payments',
$vName == 'payments'
);
JHtmlSidebar::addEntry(
JText::_('CONTACTS'),
'index.php?option=com_invoices&controller=contacts',
$vName == 'contacts'
);
JHtmlSidebar::addEntry(
JText::_('TAXES'),
'index.php?option=com_invoices&controller=taxes',
$vName == 'taxes'
);
JHtmlSidebar::addEntry(
JText::_('TEMPLATES'),
'index.php?option=com_invoices&controller=templates',
$vName == 'templates'
);
JHtmlSidebar::addEntry(
JText::_('PRODUCTS'),
'index.php?option=com_invoices&controller=templateitems',
$vName == 'products'
);
JHtmlSidebar::addEntry(
JText::_('PAYMENT_OPTIONS'),
'index.php?option=com_plugins&filter_folder=invoices'
);
JHtmlSidebar::addEntry(
JText::_('CONFIGURATION_OPTIONS'),
'index.php?option=com_config&view=component&component=com_invoices&path=&return='.urlencode(base64_encode('index.php?option=com_invoices'))
);
JHtmlSidebar::addEntry(
JText::_('CURRENCIES'),
'index.php?option=com_invoices&controller=currencies',
$vName == 'currencies'
);
}
static function getOrderOptions(){
$return = array();
$option = new stdClass();
$option->value = "i.invoice_date,desc";
$option->name = JText::_( 'ORDER_DATE_DESC' );
$return[] = $option;
$option = new stdClass();
$option->value = "i.invoice_date,asc";
$option->name = JText::_( 'ORDER_DATE_ASC' );
$return[] = $option;
$option = new stdClass();
$option->value = "i.to_name,desc";
$option->name = JText::_( 'ORDER_NAME_DESC' );
$return[] = $option;
$option = new stdClass();
$option->value = "i.to_name,asc";
$option->name = JText::_( 'ORDER_NAME_ASC' );
$return[] = $option;
$option = new stdClass();
$option->value = "i.computed_total,asc";
$option->name = JText::_( 'ORDER_VALUE_DESC' );
$return[] = $option;
$option = new stdClass();
$option->value = "i.computed_total,desc";
$option->name = JText::_( 'ORDER_VALUE_ASC' );
$return[] = $option;
return $return;
}
static function build_order_header($name, $value, $filter_order,
$filter_order_dir){
if($filter_order == $value) $hidden = "";
else $hidden = "style='display:none'" ;
if(strtoupper($filter_order_dir) == "ASC") {
$dir = "DESC" ;
$class = "";
}
elseif(strtoupper($filter_order_dir) == "DESC") {
$dir = "ASC" ;
$class = "-alt";
}
$return = "<a href='#'
onclick=\"order_by('".$value."',jQuery(this));return
false;\" data-order-dir='".$dir."' >".
JText::_($name)." <span class='glyphicon
glyphicon-sort-by-attributes".$class." order_dir_button'
".$hidden."></span></a>";
return $return;
}
static function getCurrencies()
{
$db = JFactory::getDBO();
$query = ' SELECT * FROM #__invoices_currencies '.
' WHERE currency_published = 1 '.
' ORDER BY id ASC ';
$db->setQuery( $query );
$currencies = $db->loadObjectList('id');
return $currencies;
}
static function getDefaultCurrency(){
$params = JComponentHelper::getParams( 'com_invoices' );
$db = JFactory::getDBO();
$query = "SELECT * FROM #__invoices_currencies WHERE id =
".(int)$params->get('currency_id', 1);
$db->setQuery($query);
$currency = $db->loadObject();
return $currency;
}
static function percentCurrency($currency = false){
$params = JComponentHelper::getParams( 'com_invoices' );
if(!$currency) $currency = InvoicesHelper::getDefaultCurrency();
$return = new stdClass();
$return->symbol_before = "";
$return->symbol_after = "%";
$return->decimals = (int)$params->get('decimals_tax', 0);
$return->thousands = $currency->thousands;
$return->decpoint = $currency->decpoint;
return $return;
}
public static function templateToVue($template)
{
//the language tags
$pattern = '/\[\[(.*?)\]\]/' ;
$matches = array();
preg_match_all($pattern, $template, $matches);
foreach($matches[1] as $value){
$template = str_replace("[[".$value."]]",
"{{ '".$value."' | translate }}", $template);
}
//ITEMS
$items = InvoicesHelper::get_string_between($template,
"<!--ITEMS-->", "<!--/ITEMS-->");
$search = array(
"<tr>",
"{sku}",
"{name}",
"{desc}",
"{value}",
"{amount}",
"{discount}",
"{tax}",
"{item_tax_value}",
"{item_with_tax}",
"{tax_name}",
"{item_subtotal_no_discount}",
"{item_subtotal}",
"{item_total}",
);
$replace = array(
"<tr v-for='(item, index) in invoice.items'>",
"{{ item.sku }}",
"{{ item.name }}",
"{{ item.desc }}",
"{{ item.value | currency(invoice.currency_id) }}",
"{{ item.amount }}",
"{{ item.discount | currency(invoice.currency_id) }}",
"{{ item.tax | taxpercentage }}",
"{{ invoice.taxItem(index) | currency(invoice.currency_id)
}}",
"{{ invoice.itemWithTax(index) | currency(invoice.currency_id)
}}",
"{{ item.tax_id | taxname | translate }}",
"{{ invoice.subtotalItemNoDiscount(index) |
currency(invoice.currency_id) }}",
"{{ invoice.subtotalItem(index) | currency(invoice.currency_id)
}}",
"{{ invoice.totalItem(index) | currency(invoice.currency_id)
}}",
);
$items = str_replace($search, $replace, $items) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--ITEMS-->", "<!--/ITEMS-->",
"{items}");
//TAXES
$taxes = InvoicesHelper::get_string_between($template,
"<!--TAXES-->", "<!--/TAXES-->");
$search = array(
"<tr>",
"{name}",
"{value}",
"{tax_value}",
"{calculated_on_amount}",
);
$replace = array(
"<tr v-for='(tax, index) in invoice.taxes'
v-show='tax.active'>",
"{{ tax.name | translate }}",
"{{ invoice.globaltax(tax.id) | currency(invoice.currency_id)
}}",
"{{ tax.tax_value | taxpercentageorflat(tax, invoice.currency_id)
}}",
"{{ tax.calculated_on_amount | currency(invoice.currency_id)
}}",
);
$taxes = str_replace($search, $replace, $taxes) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--TAXES-->", "<!--/TAXES-->",
"{taxes}");
//GROUPED TAXES
$grouped_taxes = InvoicesHelper::get_string_between($template,
"<!--GROUPED_TAXES-->",
"<!--/GROUPED_TAXES-->");
$search = array(
"<tr>",
"{name}",
"{value}",
"{tax_value}",
"{calculated_on_amount}",
);
$replace = array(
"<tr v-for='(tax, index) in
invoice.individualTaxes()'>",
"{{ tax.name | translate }}",
"{{ tax.value | currency(invoice.currency_id) }}",
"{{ tax.percent_value | taxpercentage }}",
"{{ tax.calculated_on_amount | currency(invoice.currency_id)
}}",
);
$grouped_taxes = str_replace($search, $replace, $grouped_taxes) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--GROUPED_TAXES-->",
"<!--/GROUPED_TAXES-->", "{grouped_taxes}");
//GROUPED TAXES TOTAL
$grouped_taxes_total = InvoicesHelper::get_string_between($template,
"<!--GROUPED_TAXES_TOTAL-->",
"<!--/GROUPED_TAXES_TOTAL-->");
$search = array(
"<tr>",
"{name}",
"{value}",
"{tax_value}",
"{calculated_on_amount}",
);
$replace = array(
"<tr v-for='(tax, index) in
invoice.individual_taxes_totals'>",
"{{ tax.name | translate }}",
"{{ tax.value | currency(invoice.currency_id) }}",
"{{ tax.tax_value | taxpercentage }}",
"{{ tax.calculated_on_amount | currency(invoice.currency_id)
}}",
);
$grouped_taxes_total = str_replace($search, $replace,
$grouped_taxes_total) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--GROUPED_TAXES_TOTAL-->",
"<!--/GROUPED_TAXES_TOTAL-->",
"{grouped_taxes_total}");
//PAYMENTS
$payments = InvoicesHelper::get_string_between($template,
"<!--PAYMENTS-->", "<!--/PAYMENTS-->");
$search = array(
"<tr>",
"{description}",
"{duedate}",
"{payment_datetime}",
"{amount}",
"href=\"{payment_link}\"",
"{payment_status}",
);
$replace = array(
"<tr v-for='(payment, index) in
getPaidPayments()'>",
"{{ payment.payment_description }}",
"{{ payment.payment_duedate | date('D MMMM YYYY',
undefined, invoice.language) }}",
"{{ payment.payment_datetime | date('D MMMM YYYY',
undefined, invoice.language) }}",
"{{ payment.payment_amount | currency(invoice.currency_id)
}}",
":href=\"payment.payment_link\"",
"<span :class=\"'label label-' +
invoice.getPaymentStatusClass(payment)\">{{
invoice.getPaymentStatusName(payment) | translate }}</span>",
);
$payments = str_replace($search, $replace, $payments) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--PAYMENTS-->", "<!--/PAYMENTS-->",
"{payments}");
//PAYMENTS2
$payments2 = InvoicesHelper::get_string_between($template,
"<!--PAYMENTS2-->", "<!--/PAYMENTS2-->");
$search = array(
"<tr>",
"{description}",
"{duedate}",
"{payment_datetime}",
"{amount}",
"href=\"{payment_link}\"",
"{payment_status}",
);
$replace = array(
"<tr v-for='(payment, index) in
getUnpaidPayments()'>",
"{{ payment.payment_description }}",
"{{ payment.payment_duedate | date('D MMMM YYYY',
undefined, invoice.language) }}",
"{{ payment.payment_datetime | date('D MMMM YYYY',
undefined, invoice.language) }}",
"{{ payment.payment_amount | currency(invoice.currency_id)
}}",
":href=\"payment.payment_link\"
target='_blank'",
"<span :class=\"'label label-' +
invoice.getPaymentStatusClass(payment)\">{{
invoice.getPaymentStatusName(payment) | translate }}</span>",
);
$payments2 = str_replace($search, $replace, $payments2) ;
$template = InvoicesHelper::replace_string_between($template,
"<!--PAYMENTS2-->", "<!--/PAYMENTS2-->",
"{payments2}");
//the tags
$search = array(
"{to_name}",
"{to_company}",
"{to_email}",
"{to_address}",
"{from_name}",
"{from_address}",
"{from_num}",
"{from_url}",
"{from_email}",
"{from_phone}",
"{invoice_date}",
"{notes}",
"{invoice_num}",
"{items}",
"{subtotal}",
"{taxes}",
"{grouped_taxes}",
"{grouped_taxes_total}",
"{total}",
"{payments}",
"{payments2}",
"{total_payments}",
"{amount_outstanding}",
"{to_zipcode}",
"{to_city}",
"{to_state}",
"{to_country}",
"{to_vatid}",
"{discount}",
"{invoice_duedate}",
"{status}",
"{num_payments_received}",
"{num_pending_payments}",
"{to_phone}",
"{invoice_link}",
"{invoice_unlogged_link}",
"{subtotal_items}",
"{subtotal_items_less_total_discount}",
"{external_ref}",
"{paynow_button}",
"{total_items_tax}",
"{subtotal_items_no_discount}",
"{total_items_discount}",
"{accept_button}",
"{reject_button}"
);
$replace = array(
"{{ invoice.to_name }}",
"{{ invoice.to_company }}",
"{{ invoice.to_email }}",
"<div
v-html='nl2br(invoice.to_address)'></div>",
"{{ invoice.from_name }}",
"<div
v-html='nl2br(invoice.from_address)'></div>",
"{{ invoice.from_num }}",
"{{ invoice.from_url }}",
"{{ invoice.from_email }}",
"{{ invoice.from_phone }}",
"{{ invoice.invoice_date | date('D MMMM YYYY', undefined,
invoice.language) }}",
"<div v-html='invoice.notes'></div>",
"{{ invoice.invoice_num }}",
//ITEMS
$items,
"{{ invoice.subtotal_items() | currency(invoice.currency_id)
}}",
//TAXES
$taxes,
//GROUPED TAXES
$grouped_taxes,
//GROUPED TAXES TOTAL
$grouped_taxes_total,
"{{ invoice.thetotal() | currency(invoice.currency_id) }}",
//PAYMENTS
$payments,
//PAYMENTS2
$payments2,
"{{ invoice.total_payments }}",
"{{ invoice.total_unpaid | currency(invoice.currency_id) }}",
"{{ invoice.to_zipcode }}",
"{{ invoice.to_city }}",
"{{ invoice.to_state }}",
"{{ invoice.to_country }}",
"{{ invoice.to_vatid }}",
"{{ invoice.discount | currency(invoice.currency_id) }}",
"{{ invoice.invoice_duedate | date('D MMMM YYYY',
undefined, invoice.language) }}",
"<span :class=\"'label label-' +
status_class\">{{ status_name }}</span>",
"{{ invoice.num_payments_received }}",
"{{ invoice.num_pending_payments }}",
"{{ invoice.to_phone }}",
"{{ invoice.link }}",
"{{ invoice.public_link }}",
"{{ invoice.subtotal_items() | currency(invoice.currency_id)
}}",
"{{ invoice.subtotal_items() | currency(invoice.currency_id)
}}",
"{{ invoice.external_ref }}",
"<div v-html='paynow_button'></div>",
"{{ invoice.individual_taxes_totals | currency(invoice.currency_id)
}}",
"{subtotal_items_no_discount}",
"{total_items_discount}",
"<div v-html='accept_button'></div>",
"<div v-html='reject_button'></div>",
);
$template = str_replace($search, $replace, $template) ;
return $template;
}
/**
* Get an array of all the taxes defined in the system
* @return array An array of objects, each containing the tax element from
the DB
*/
public static function getAllTaxes(){
$db = JFactory::getDBO();
$query = ' SELECT * FROM #__invoices_taxes ORDER BY ordering, name
';
$db->setQuery( $query );
$alltaxes = $db->loadObjectList();
return $alltaxes;
}
public static function getTemplatesData(){
$db = JFactory::getDBO();
$query = ' SELECT * FROM #__invoices_templates '.
' ORDER BY name ';
$db->setQuery( $query );
$templates_data = $db->loadObjectList();
return $templates_data;
}
/**
* Get an array of the taxes that are set to be displayed as columns
* @return array An array of objects, each containing the tax element from
the DB
*/
public static function getTaxes(){
$db = JFactory::getDBO();
$query = ' SELECT * FROM #__invoices_taxes WHERE show_column = 1
ORDER BY ordering, name ';
$db->setQuery( $query );
$taxes = $db->loadObjectList();
return $taxes;
}
public static function loadStatusLanguageStrings()
{
JText::script('PAID');
JText::script('ACCEPTED');
JText::script('ACCEPTED_CLIENT');
JText::script('PENDING');
JText::script('PARTIAL_PAID');
JText::script('PASTDUE');
JText::script('REJECTED');
JText::script('REJECTED_CLIENT');
JText::script('REFUNDED');
JText::script('PARTIAL_REFUNDED');
JText::script('CANCELLED');
JText::script('EXPIRED');
JText::script('CORRECTED');
JText::script('UNPAID_ONTIME');
JText::script('PAID_LATE');
}
public static function sendJSONResponse($object, $status = 200){
$app = JFactory::getApplication();
switch($status){
case 403:
header('HTTP/1.0 403 Forbidden');
break;
default:
break;
}
header('Content-Type: application/json');
echo json_encode($object);
$app->close();
}
public static function storepdf($location, $view)
{
jimport( 'joomla.html.html');
require_once(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'dompdf'.DS.'autoload.inc.php');
if(file_exists(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'html.php'))
require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'html.php');
elseif(file_exists(JPATH_SITE.DS.'libraries'.DS.'cms'.DS.'html'.DS.'html.php'))
require_once(JPATH_SITE.DS.'libraries'.DS.'cms'.DS.'html'.DS.'html.php');
if(file_exists(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'date'.DS.'date.php'))
require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'date'.DS.'date.php');
elseif(file_exists(JPATH_SITE.DS.'libraries'.DS.'cms'.DS.'html'.DS.'date.php'))
require_once(JPATH_SITE.DS.'libraries'.DS.'cms'.DS.'html'.DS.'date.php');
$mainframe = JFactory::getApplication();
$plantilla = 'email' ;
$html = $view->loadTemplate($plantilla);
$search = array("€", "¢", "£",
"¤", "¥");
$replace = array("€", "¢",
"£", "¤", "¥");
$html = str_replace($search, $replace, $html);
$html = mb_convert_encoding($html, 'HTML-ENTITIES',
'UTF-8');
$html = utf8_decode($html);
$html = '<!DOCTYPE HTML>
<html>
<body>
<style>
'.$view->template->styles.'
</style>'
. $html .
'</body></html>';
$options = new Dompdf\Options();
$options->set( 'isRemoteEnabled', TRUE );
$dompdf = new Dompdf\Dompdf($options);
$dompdf->set_paper('a4');
$dompdf->load_html($html);
$dompdf->render();
$pdf = $dompdf->output();
return file_put_contents($location, $pdf);
}
}
PK[��[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK[��[n?3��version.phpnu�[���<?php
/*------------------------------------------------------------------------
# com_invoices - Invoices for Joomla
# ------------------------------------------------------------------------
# author Germinal Camps
# copyright Copyright (C) 2012 JoomlaFinances.com. All Rights Reserved.
# @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.JoomlaFinances.com
# Technical Support: Forum - http://www.JoomlaFinances.com/forum
-------------------------------------------------------------------------*/
//no direct access
defined('_JEXEC') or die('Restricted access.');
class InvoicesVersion{
static function show_footer(){
return "";
}
}PK��[3�,h�� route.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Component Route Helper
*
* @since 1.5
*/
abstract class NewsfeedsHelperRoute
{
/**
* getNewsfeedRoute
*
* @param int $id menu itemid
* @param int $catid category id
* @param int $language language
*
* @return string
*/
public static function getNewsfeedRoute($id, $catid, $language = 0)
{
// Create the link
$link =
'index.php?option=com_newsfeeds&view=newsfeed&id=' . $id;
if ((int) $catid > 1)
{
$link .= '&catid=' . $catid;
}
if ($language && $language !== '*' &&
JLanguageMultilang::isEnabled())
{
$link .= '&lang=' . $language;
}
return $link;
}
/**
* getCategoryRoute
*
* @param int $catid category id
* @param int $language language
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
}
else
{
$id = (int) $catid;
}
if ($id < 1)
{
$link = '';
}
else
{
// Create the link
$link =
'index.php?option=com_newsfeeds&view=category&id=' . $id;
if ($language && $language !== '*' &&
JLanguageMultilang::isEnabled())
{
$link .= '&lang=' . $language;
}
}
return $link;
}
}
PK���[��B��7�7html/filter.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/language.php');
/**
* Filter HTML Behaviors for Finder.
*
* @since 2.5
*/
abstract class JHtmlFilter
{
/**
* Method to generate filters using the slider widget and decorated
* with the FinderFilter JavaScript behaviors.
*
* @param array $options An array of configuration options. [optional]
*
* @return mixed A rendered HTML widget on success, null otherwise.
*
* @since 2.5
*/
public static function slider($options = array())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$html = '';
$filter = null;
// Get the configuration options.
$filterId = array_key_exists('filter_id', $options) ?
$options['filter_id'] : null;
$activeNodes = array_key_exists('selected_nodes', $options) ?
$options['selected_nodes'] : array();
$classSuffix = array_key_exists('class_suffix', $options) ?
$options['class_suffix'] : '';
// Load the predefined filter if specified.
if (!empty($filterId))
{
$query->select('f.data, f.params')
->from($db->quoteName('#__finder_filters') . ' AS
f')
->where('f.filter_id = ' . (int) $filterId);
// Load the filter data.
$db->setQuery($query);
try
{
$filter = $db->loadObject();
}
catch (RuntimeException $e)
{
return null;
}
// Initialize the filter parameters.
if ($filter)
{
$filter->params = new Registry($filter->params);
}
}
// Build the query to get the branch data and the number of child nodes.
$query->clear()
->select('t.*, count(c.id) AS children')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t')
->join('INNER',
$db->quoteName('#__finder_taxonomy') . ' AS c ON
c.parent_id = t.id')
->where('t.parent_id = 1')
->where('t.state = 1')
->where('t.access IN (' . $groups . ')')
->group('t.id, t.parent_id, t.state, t.access, t.ordering,
t.title, c.parent_id')
->order('t.ordering, t.title');
// Limit the branch children to a predefined filter.
if ($filter)
{
$query->where('c.id IN(' . $filter->data .
')');
}
// Load the branches.
$db->setQuery($query);
try
{
$branches = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
return null;
}
// Check that we have at least one branch.
if (count($branches) === 0)
{
return null;
}
$branch_keys = array_keys($branches);
$html .= JHtml::_('bootstrap.startAccordion',
'accordion', array('parent' => true,
'active' => 'accordion-' . $branch_keys[0])
);
// Load plugin language files.
FinderHelperLanguage::loadPluginLanguage();
// Iterate through the branches and build the branch groups.
foreach ($branches as $bk => $bv)
{
// If the multi-lang plugin is enabled then drop the language branch.
if ($bv->title === 'Language' &&
JLanguageMultilang::isEnabled())
{
continue;
}
// Build the query to get the child nodes for this branch.
$query->clear()
->select('t.*')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t')
->where('t.parent_id = ' . (int) $bk)
->where('t.state = 1')
->where('t.access IN (' . $groups . ')')
->order('t.ordering, t.title');
// Self-join to get the parent title.
$query->select('e.title AS parent_title')
->join('LEFT',
$db->quoteName('#__finder_taxonomy', 'e') . '
ON ' . $db->quoteName('e.id') . ' = ' .
$db->quoteName('t.parent_id'));
// Load the branches.
$db->setQuery($query);
try
{
$nodes = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
return null;
}
// Translate node titles if possible.
$lang = JFactory::getLanguage();
foreach ($nodes as $nk => $nv)
{
if (trim($nv->parent_title, '**') ===
'Language')
{
$title = FinderHelperLanguage::branchLanguageTitle($nv->title);
}
else
{
$key = FinderHelperLanguage::branchPlural($nv->title);
$title = $lang->hasKey($key) ? JText::_($key) : $nv->title;
}
$nodes[$nk]->title = $title;
}
// Adding slides
$html .= JHtml::_('bootstrap.addSlide',
'accordion',
JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL',
JText::_(FinderHelperLanguage::branchSingular($bv->title)) . '
- ' . count($nodes)
),
'accordion-' . $bk
);
// Populate the toggle button.
$html .= '<button class="btn jform-rightbtn"
type="button"
onclick="jQuery(\'[id="tax-'
. $bk .
'"]\').each(function(){this.click();});"><span
class="icon-checkbox-partial"></span> '
. JText::_('JGLOBAL_SELECTION_INVERT') .
'</button><hr/>';
// Populate the group with nodes.
foreach ($nodes as $nk => $nv)
{
// Determine if the node should be checked.
$checked = in_array($nk, $activeNodes) ? '
checked="checked"' : '';
// Build a node.
$html .= '<div class="control-group">';
$html .= '<div class="controls">';
$html .= '<label class="checkbox">';
$html .= '<input type="checkbox" class="selector
filter-node' . $classSuffix . '" value="' . $nk .
'" name="t[]" id="tax-'
. $bk . '"' . $checked . ' />';
$html .= $nv->title;
$html .= '</label>';
$html .= '</div>';
$html .= '</div>';
}
$html .= JHtml::_('bootstrap.endSlide');
}
$html .= JHtml::_('bootstrap.endAccordion');
return $html;
}
/**
* Method to generate filters using select box dropdown controls.
*
* @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object.
* @param array $options An array of options.
*
* @return mixed A rendered HTML widget on success, null otherwise.
*
* @since 2.5
*/
public static function select($idxQuery, $options)
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$filter = null;
// Get the configuration options.
$classSuffix = $options->get('class_suffix', null);
$showDates = $options->get('show_date_filters', false);
// Try to load the results from cache.
$cache = JFactory::getCache('com_finder', '');
$cacheId = 'filter_select_' .
serialize(array($idxQuery->filter, $options, $groups,
JFactory::getLanguage()->getTag()));
// Check the cached results.
if ($cache->contains($cacheId))
{
$branches = $cache->get($cacheId);
}
else
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Load the predefined filter if specified.
if (!empty($idxQuery->filter))
{
$query->select('f.data, ' .
$db->quoteName('f.params'))
->from($db->quoteName('#__finder_filters') . ' AS
f')
->where('f.filter_id = ' . (int) $idxQuery->filter);
// Load the filter data.
$db->setQuery($query);
try
{
$filter = $db->loadObject();
}
catch (RuntimeException $e)
{
return null;
}
// Initialize the filter parameters.
if ($filter)
{
$filter->params = new Registry($filter->params);
}
}
// Build the query to get the branch data and the number of child nodes.
$query->clear()
->select('t.*, count(c.id) AS children')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t')
->join('INNER',
$db->quoteName('#__finder_taxonomy') . ' AS c ON
c.parent_id = t.id')
->where('t.parent_id = 1')
->where('t.state = 1')
->where('t.access IN (' . $groups . ')')
->where('c.state = 1')
->where('c.access IN (' . $groups . ')')
->group($db->quoteName('t.id'))
->order('t.ordering, t.title');
// Limit the branch children to a predefined filter.
if (!empty($filter->data))
{
$query->where('c.id IN(' . $filter->data .
')');
}
// Load the branches.
$db->setQuery($query);
try
{
$branches = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
return null;
}
// Check that we have at least one branch.
if (count($branches) === 0)
{
return null;
}
// Iterate through the branches and build the branch groups.
foreach ($branches as $bk => $bv)
{
// If the multi-lang plugin is enabled then drop the language branch.
if ($bv->title === 'Language' &&
JLanguageMultilang::isEnabled())
{
continue;
}
// Build the query to get the child nodes for this branch.
$query->clear()
->select('t.*')
->from($db->quoteName('#__finder_taxonomy') . '
AS t')
->where('t.parent_id = ' . (int) $bk)
->where('t.state = 1')
->where('t.access IN (' . $groups . ')')
->order('t.ordering, t.title');
// Self-join to get the parent title.
$query->select('e.title AS parent_title')
->join('LEFT',
$db->quoteName('#__finder_taxonomy', 'e') . '
ON ' . $db->quoteName('e.id') . ' = ' .
$db->quoteName('t.parent_id'));
// Limit the nodes to a predefined filter.
if (!empty($filter->data))
{
$query->where('t.id IN(' . $filter->data .
')');
}
// Load the branches.
$db->setQuery($query);
try
{
$branches[$bk]->nodes = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
return null;
}
// Translate branch nodes if possible.
$language = JFactory::getLanguage();
foreach ($branches[$bk]->nodes as $node_id => $node)
{
if (trim($node->parent_title, '**') ===
'Language')
{
$title = FinderHelperLanguage::branchLanguageTitle($node->title);
}
else
{
$key = FinderHelperLanguage::branchPlural($node->title);
$title = $language->hasKey($key) ? JText::_($key) :
$node->title;
}
$branches[$bk]->nodes[$node_id]->title = $title;
}
// Add the Search All option to the branch.
array_unshift($branches[$bk]->nodes, array('id' =>
null, 'title' =>
JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL')));
}
// Store the data in cache.
$cache->store($branches, $cacheId);
}
$html = '';
// Add the dates if enabled.
if ($showDates)
{
$html .= JHtml::_('filter.dates', $idxQuery, $options);
}
$html .= '<div class="filter-branch' . $classSuffix .
' control-group clearfix">';
// Iterate through all branches and build code.
foreach ($branches as $bk => $bv)
{
// If the multi-lang plugin is enabled then drop the language branch.
if ($bv->title === 'Language' &&
JLanguageMultilang::isEnabled())
{
continue;
}
$active = null;
// Check if the branch is in the filter.
if (array_key_exists($bv->title, $idxQuery->filters))
{
// Get the request filters.
$temp =
JFactory::getApplication()->input->request->get('t',
array(), 'array');
// Search for active nodes in the branch and get the active node.
$active = array_intersect($temp, $idxQuery->filters[$bv->title]);
$active = count($active) === 1 ? array_shift($active) : null;
}
// Build a node.
$html .= '<div class="controls
finder-selects">';
$html .= '<label for="tax-' .
JFilterOutput::stringURLSafe($bv->title) . '"
class="control-label">';
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL',
JText::_(FinderHelperLanguage::branchSingular($bv->title)));
$html .= '</label>';
$html .= '<br />';
$html .= JHtml::_(
'select.genericlist',
$branches[$bk]->nodes, 't[]', 'class="inputbox
advancedSelect"', 'id', 'title', $active,
'tax-' . JFilterOutput::stringURLSafe($bv->title)
);
$html .= '</div>';
}
$html .= '</div>';
return $html;
}
/**
* Method to generate fields for filtering dates
*
* @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object.
* @param array $options An array of options.
*
* @return mixed A rendered HTML widget on success, null otherwise.
*
* @since 2.5
*/
public static function dates($idxQuery, $options)
{
$html = '';
// Get the configuration options.
$classSuffix = $options->get('class_suffix', null);
$loadMedia = $options->get('load_media', true);
$showDates = $options->get('show_date_filters', false);
if (!empty($showDates))
{
// Build the date operators options.
$operators = array();
$operators[] = JHtml::_('select.option', 'before',
JText::_('COM_FINDER_FILTER_DATE_BEFORE'));
$operators[] = JHtml::_('select.option', 'exact',
JText::_('COM_FINDER_FILTER_DATE_EXACTLY'));
$operators[] = JHtml::_('select.option', 'after',
JText::_('COM_FINDER_FILTER_DATE_AFTER'));
// Load the CSS/JS resources.
if ($loadMedia)
{
JHtml::_('stylesheet', 'com_finder/dates.css',
array('version' => 'auto', 'relative'
=> true));
}
// Open the widget.
$html .= '<ul
id="finder-filter-select-dates">';
// Start date filter.
$attribs['class'] = 'input-medium';
$html .= '<li class="filter-date' . $classSuffix .
'">';
$html .= '<label for="filter_date1"
class="hasTooltip" title ="' .
JText::_('COM_FINDER_FILTER_DATE1_DESC') .
'">';
$html .= JText::_('COM_FINDER_FILTER_DATE1');
$html .= '</label>';
$html .= '<br />';
$html .= JHtml::_(
'select.genericlist',
$operators, 'w1', 'class="inputbox
filter-date-operator advancedSelect"', 'value',
'text', $idxQuery->when1, 'finder-filter-w1'
);
$html .= JHtml::_('calendar', $idxQuery->date1,
'd1', 'filter_date1', '%Y-%m-%d', $attribs);
$html .= '</li>';
// End date filter.
$html .= '<li class="filter-date' . $classSuffix .
'">';
$html .= '<label for="filter_date2"
class="hasTooltip" title ="' .
JText::_('COM_FINDER_FILTER_DATE2_DESC') .
'">';
$html .= JText::_('COM_FINDER_FILTER_DATE2');
$html .= '</label>';
$html .= '<br />';
$html .= JHtml::_(
'select.genericlist',
$operators, 'w2', 'class="inputbox
filter-date-operator advancedSelect"', 'value',
'text', $idxQuery->when2, 'finder-filter-w2'
);
$html .= JHtml::_('calendar', $idxQuery->date2,
'd2', 'filter_date2', '%Y-%m-%d', $attribs);
$html .= '</li>';
// Close the widget.
$html .= '</ul>';
}
return $html;
}
}
PK���[��f��html/query.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Query HTML behavior class for Finder.
*
* @since 2.5
*/
abstract class JHtmlQuery
{
/**
* Method to get the explained (human-readable) search query.
*
* @param FinderIndexerQuery $query A FinderIndexerQuery object to
explain.
*
* @return mixed String if there is data to explain, null otherwise.
*
* @since 2.5
*/
public static function explained(FinderIndexerQuery $query)
{
$parts = array();
// Process the required tokens.
foreach ($query->included as $token)
{
if ($token->required && (!isset($token->derived) ||
$token->derived == false))
{
$parts[] = '<span class="query-required">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_REQUIRED',
$token->term) . '</span>';
}
}
// Process the optional tokens.
foreach ($query->included as $token)
{
if (!$token->required && (!isset($token->derived) ||
$token->derived == false))
{
$parts[] = '<span class="query-optional">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_OPTIONAL',
$token->term) . '</span>';
}
}
// Process the excluded tokens.
foreach ($query->excluded as $token)
{
if (!isset($token->derived) || $token->derived === false)
{
$parts[] = '<span class="query-excluded">' .
JText::sprintf('COM_FINDER_QUERY_TOKEN_EXCLUDED',
$token->term) . '</span>';
}
}
// Process the start date.
if ($query->date1)
{
$date =
JFactory::getDate($query->date1)->format(JText::_('DATE_FORMAT_LC'));
$datecondition = JText::_('COM_FINDER_QUERY_DATE_CONDITION_' .
strtoupper($query->when1));
$parts[] = '<span class="query-start-date">' .
JText::sprintf('COM_FINDER_QUERY_START_DATE', $datecondition,
$date) . '</span>';
}
// Process the end date.
if ($query->date2)
{
$date =
JFactory::getDate($query->date2)->format(JText::_('DATE_FORMAT_LC'));
$datecondition = JText::_('COM_FINDER_QUERY_DATE_CONDITION_' .
strtoupper($query->when2));
$parts[] = '<span class="query-end-date">' .
JText::sprintf('COM_FINDER_QUERY_END_DATE', $datecondition,
$date) . '</span>';
}
// Process the taxonomy filters.
if (!empty($query->filters))
{
// Get the filters in the request.
$t =
JFactory::getApplication()->input->request->get('t',
array(), 'array');
// Process the taxonomy branches.
foreach ($query->filters as $branch => $nodes)
{
// Process the taxonomy nodes.
$lang = JFactory::getLanguage();
foreach ($nodes as $title => $id)
{
// Translate the title for Types
$key = FinderHelperLanguage::branchPlural($title);
if ($lang->hasKey($key))
{
$title = JText::_($key);
}
// Don't include the node if it is not in the request.
if (!in_array($id, $t))
{
continue;
}
// Add the node to the explanation.
$parts[] = '<span class="query-taxonomy">'
. JText::sprintf('COM_FINDER_QUERY_TAXONOMY_NODE', $title,
JText::_(FinderHelperLanguage::branchSingular($branch)))
. '</span>';
}
}
}
// Build the interpreted query.
return count($parts) ?
JText::sprintf('COM_FINDER_QUERY_TOKEN_INTERPRETED',
implode(JText::_('COM_FINDER_QUERY_TOKEN_GLUE'), $parts)) : null;
}
/**
* Method to get the suggested search query.
*
* @param FinderIndexerQuery $query A FinderIndexerQuery object.
*
* @return mixed String if there is a suggestion, false otherwise.
*
* @since 2.5
*/
public static function suggested(FinderIndexerQuery $query)
{
$suggested = false;
// Check if the query input is empty.
if (empty($query->input))
{
return $suggested;
}
// Check if there were any ignored or included keywords.
if (count($query->ignored) || count($query->included))
{
$suggested = $query->input;
// Replace the ignored keyword suggestions.
foreach (array_reverse($query->ignored) as $token)
{
if (isset($token->suggestion))
{
$suggested = str_ireplace($token->term, $token->suggestion,
$suggested);
}
}
// Replace the included keyword suggestions.
foreach (array_reverse($query->included) as $token)
{
if (isset($token->suggestion))
{
$suggested = str_ireplace($token->term, $token->suggestion,
$suggested);
}
}
// Check if we made any changes.
if ($suggested == $query->input)
{
$suggested = false;
}
}
return $suggested;
}
}
PKK!�[�
�
� blank.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blank.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Blank component helper
*/
abstract class BlankHelper
{
/**
* Composer Switch
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* Load the Composer Vendors
*/
public static function composerAutoload($target)
{
// insure we load the composer vendor only once
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
return self::{$functionName}();
}
return false;
}
return self::$composer[$target];
}
/**
* Convert it into a string
*/
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
/**
* Load the Component xml manifest.
*/
public static function manifest()
{
$manifestUrl =
JPATH_ADMINISTRATOR."/components/com_blank/blank.xml";
return simplexml_load_file($manifestUrl);
}
/**
* Joomla version object
*/
protected static $JVersion;
/**
* set/get Joomla version
*/
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
{
self::$JVersion = new JVersion();
}
return self::$JVersion;
}
/**
* Load the Contributors details.
*/
public static function getContributors()
{
// get params
$params = JComponentHelper::getParams('com_blank');
// start contributors array
$contributors = array();
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
if ((NULL !== $params->get("showContributor".$nr))
&& ($params->get("showContributor".$nr) == 2 ||
$params->get("showContributor".$nr) == 3))
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
$link_front = '<a
href="mailto:'.$params->get("emailContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a
href="'.$params->get("linkContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
else
{
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] =
self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] =
$link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
}
/**
* Can be used to build help urls.
**/
public static function getHelpUrl($view)
{
return false;
}
/**
* Get any component's model
*/
public static function getModel($name, $path = JPATH_COMPONENT_SITE,
$Component = 'Blank', $config = array())
{
// fix the name
$name = self::safeString($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component .
'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) ||
!self::checkString($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR .
'/components/com_' . strtolower($Component) .
'/tables';
}
// get instance
$model = JModelLegacy::getInstance($name, $Component . 'Model',
$config);
// if model not found (strange)
if ($model == false)
{
jimport('joomla.filesystem.file');
// get file path
$filePath = $path . '/' . $name . '.php';
$fullPathModel = $fullPathModels . '/' . $name .
'.php';
// check if it exists
if (File::exists($filePath))
{
// get the file
require_once $filePath;
}
elseif (File::exists($fullPathModel))
{
// get the file
require_once $fullPathModel;
}
// build class names
$modelClass = $Component . 'Model' . $name;
if (class_exists($modelClass))
{
// initialize the model
return new $modelClass($config);
}
}
return $model;
}
/**
* Add to asset Table
*/
public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_blank');
$parentId = $parent->id;
$name = 'com_blank.'.$table.'.'.$id;
$title = '';
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
$error = $asset->getError();
if ($error)
{
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if ($asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
$rules = self::getDefaultAssetRules('com_blank', $table,
$inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
}
if (!$asset->check() || !$asset->store())
{
JFactory::getApplication()->enqueueMessage($asset->getError(),
'warning');
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $id;
$object->asset_id = (int) $asset->id;
// Update their asset_id to link to the asset table.
return
JFactory::getDbo()->updateObject('#__blank_'.$table, $object,
'id');
}
}
return false;
}
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view, $inherit
= true)
{
// if new or inherited
$assetId = 0;
// Only get the actual item rules if not inheriting
if (!$inherit)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$db->execute();
// check that there is a value
if ($db->getNumRows())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
}
}
// get asset rules
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules)
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($view !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
elseif ($inherit)
{
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count((array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
// return filtered rules
return $rules;
}
}
return $result;
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference, or a stdClass object containing a comment
attribute to be injected before the XML node and a fieldXML attribute
containing a SimpleXMLElement
*
* @return null
*
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return null
*
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAddOptions
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
*
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default =
'', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) &&
isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],
true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
}
/**
* Render Bool Button
*
* @param array $args All the args for the button
* 0) name
* 1) additional (options class) // not used
at this time
* 2) default
* 3) yes (name)
* 4) no (name)
*
* @return string The input html of the button
*
*/
public static function renderBoolButton()
{
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not
used at this time
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) :
'bool_button',
'label' => isset($args[0]) ?
self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool
Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) :
'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) :
'JNO');
// return the input
return self::getFieldObject($buttonAttributes,
$buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Get a variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= 'blank')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= 'blank', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
$type = 'item';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.published'));
$query->from('#__blank_'.$type.' AS a');
$query->where('a.id = '. (int) $id);
$query->where('a.published = 1');
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return true;
}
return false;
}
public static function getGroupName($id)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(array('a.title'));
$query->from('#__usergroups AS a');
$query->where('a.id = '. (int) $id);
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return $db->loadResult();
}
return $id;
}
/**
* Get the action permissions
*
* @param string $view The related view name
* @param int $record The item to act upon
* @param string $views The related list view name
* @param mixed $target Only get this permission (like edit,
create, delete)
* @param string $component The target component
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*/
public static function getActions($view, &$record = null, $views =
null, $target = null, $component = 'blank', $user =
'null')
{
// load the user if not given
if (!self::checkObject($user))
{
// get the user object
$user = JFactory::getUser();
}
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
{
$views = self::safeString($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_' . $component .
'/access.xml',
"/access/section[@name='component']/"
);
// if non found then return empty JObject
if (empty($actions))
{
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by)
&& isset($record->id))
{
$record->created_by = self::getVar($view, $record->id,
'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin',
'core.manage', 'core.options',
'core.export');
// check if we have a target
$checkTarget = false;
if ($target)
{
// convert to an array
if (self::checkString($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
{
$checkTarget = true;
}
}
// loop the actions and set the permissions
foreach ($actions as $action)
{
// check target action filter
if ($checkTarget && self::filterActions($view, $action->name,
$target))
{
continue;
}
// set to use component default
$fallback = true;
// reset permission per/action
$permission = false;
$catpermission = false;
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a
component action)
if (self::checkObject($record) && isset($record->id)
&& $record->id > 0 && !in_array($action->name,
$componentActions) &&
(strpos($action->name, 'core.') !== false ||
strpos($action->name, $view . '.') !== false))
{
// we are in item
$area = 'item';
// The record has been set. Check the record permissions.
$permission = $user->authorise($action->name, 'com_' .
$component . '.' . $view . '.' . (int) $record->id);
// if no permission found, check edit own
if (!$permission)
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// the correct target
$coreCheck = (array) explode('.', $action->name);
// check that we have both local and global access
if ($user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component . '.' . $view . '.' .
(int) $record->id) &&
$user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
elseif (self::checkString($views) && isset($record->catid)
&& $record->catid > 0)
{
// we are in item
$area = 'category';
// set the core check
$coreCheck = explode('.', $action->name);
$core = $coreCheck[0];
// make sure we use the core. action check for the categories
if (strpos($action->name, $view) !== false &&
strpos($action->name, 'core.') === false )
{
$coreCheck[0] = 'core';
$categoryCheck = implode('.', $coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid);
if (!$catpermission && !is_null($catpermission))
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// check that we have both local and global access
if ($user->authorise('core.edit.own', 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid) &&
$user->authorise($core . '.edit.own', 'com_'
. $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
}
}
// if allowed then fallback on component global settings
if ($fallback)
{
// if item/category blocks access then don't fall back on global
if ((($area === 'item') && !$permission) || (($area
=== 'category') && !$catpermission))
{
// do not allow
$result->set($action->name, false);
}
// Finally remember the global settings have the final say. (even if
item allow)
// The local item permissions can block, but it can't open and
override of global permissions.
// Since items are created by users and global permissions is set by
system admin.
else
{
$result->set($action->name,
$user->authorise($action->name, 'com_' . $component));
}
}
}
return $result;
}
/**
* Filter the action permissions
*
* @param string $action The action to check
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*/
protected static function filterActions(&$view, &$action,
&$targets)
{
foreach ($targets as $target)
{
if (strpos($action, $view . '.' . $target) !== false ||
strpos($action, 'core.' . $target) !== false)
{
return false;
break;
}
}
return true;
}
/**
* Check if have an json string
*
* @input string The json string to check
*
* @returns bool true on success
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr =
count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
}
/**
* Check if have a string with a length
*
* @input string The string to check
*
* @returns bool true on success
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) &&
strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Check if we are connected
* Thanks https://stackoverflow.com/a/4860432/1429677
*
* @returns bool true on success
*/
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down,
since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
$is_conn = true;
fclose($connected);
}
else
{
//action in connection failure
$is_conn = false;
}
return $is_conn;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
// typo sorry!
public static function sorten($string, $length = 40, $addTip = true)
{
return self::shorten($string, $length, $addTip);
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip"
title="'.$title.'"
style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag =
JComponentHelper::getParams('com_blank')->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var,
ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
}
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*/
public static function randomkey($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
PKK!�[8A+��category.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content Component Category Tree
*
* @since 1.6
*/
class NewsfeedsCategories extends JCategories
{
/**
* Constructor
*
* @param array $options options
*/
public function __construct($options = array())
{
$options['table'] = '#__newsfeeds';
$options['extension'] = 'com_newsfeeds';
$options['statefield'] = 'published';
parent::__construct($options);
}
}
PKK!�[{�]���headercheck.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage headercheck.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
class blankHeaderCheck
{
function js_loaded($script_name)
{
// UIkit check point
if (strpos($script_name,'uikit') !== false)
{
$app = JFactory::getApplication();
$getTemplateName =
$app->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false)
{
return true;
}
}
$document = JFactory::getDocument();
$head_data = $document->getHeadData();
foreach (array_keys($head_data['scripts']) as $script)
{
if (stristr($script, $script_name))
{
return true;
}
}
return false;
}
function css_loaded($script_name)
{
// UIkit check point
if (strpos($script_name,'uikit') !== false)
{
$app = JFactory::getApplication();
$getTemplateName =
$app->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false)
{
return true;
}
}
$document = JFactory::getDocument();
$head_data = $document->getHeadData();
foreach (array_keys($head_data['styleSheets']) as $script)
{
if (stristr($script, $script_name))
{
return true;
}
}
return false;
}
}PK�,�[tL�99 media.phpnu�[���<?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Media helper class.
*
* @since 1.6
* @deprecated 4.0 Use JHelperMedia instead
*/
abstract class MediaHelper
{
/**
* Checks if the file is an image
*
* @param string $fileName The filename
*
* @return boolean
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::isImage instead
*/
public static function isImage($fileName)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::isImage()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->isImage($fileName);
}
/**
* Gets the file extension for the purpose of using an icon.
*
* @param string $fileName The filename
*
* @return string File extension
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::getTypeIcon instead
*/
public static function getTypeIcon($fileName)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::getTypeIcon()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->getTypeIcon($fileName);
}
/**
* Checks if the file can be uploaded
*
* @param array $file File information
* @param string $error An error message to be returned
*
* @return boolean
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::canUpload instead
*/
public static function canUpload($file, $error = '')
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::canUpload()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->canUpload($file, 'com_media');
}
/**
* Method to parse a file size
*
* @param integer $size The file size in bytes
*
* @return string The converted file size
*
* @since 1.6
* @deprecated 4.0 Use JHtml::_('number.bytes') instead
*/
public static function parseSize($size)
{
try
{
JLog::add(
sprintf("%s() is deprecated. Use
JHtml::_('number.bytes') instead.", __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
return JHtml::_('number.bytes', $size);
}
/**
* Calculate the size of a resized image
*
* @param integer $width Image width
* @param integer $height Image height
* @param integer $target Target size
*
* @return array The new width and height
*
* @since 3.2
* @deprecated 4.0 Use JHelperMedia::imageResize instead
*/
public static function imageResize($width, $height, $target)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::imageResize()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->imageResize($width, $height, $target);
}
/**
* Counts the files and directories in a directory that are not php or
html files.
*
* @param string $dir Directory name
*
* @return array The number of files and directories in the given
directory
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::countFiles instead
*/
public static function countFiles($dir)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::countFiles()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->countFiles($dir);
}
}
PK>�[���X��association.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('NewsfeedsHelper', JPATH_ADMINISTRATOR .
'/components/com_newsfeeds/helpers/newsfeeds.php');
JLoader::register('NewsfeedsHelperRoute', JPATH_SITE .
'/components/com_newsfeeds/helpers/route.php');
JLoader::register('CategoryHelperAssociation',
JPATH_ADMINISTRATOR .
'/components/com_categories/helpers/association.php');
/**
* Newsfeeds Component Association Helper
*
* @since 3.0
*/
abstract class NewsfeedsHelperAssociation extends CategoryHelperAssociation
{
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
$jinput = JFactory::getApplication()->input;
$view = $view === null ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view === 'newsfeed')
{
if ($id)
{
$associations =
JLanguageAssociations::getAssociations('com_newsfeeds',
'#__newsfeeds', 'com_newsfeeds.item', $id);
$return = array();
foreach ($associations as $tag => $item)
{
$return[$tag] = NewsfeedsHelperRoute::getNewsfeedRoute($item->id,
(int) $item->catid, $item->language);
}
return $return;
}
}
if ($view === 'category' || $view === 'categories')
{
return self::getCategoryAssociations($id, 'com_newsfeeds');
}
return array();
}
}
PK>�[�����legacyrouter.phpnu�[���<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Legacy routing rules class from com_newsfeeds
*
* @since 3.6
* @deprecated 4.0
*/
class NewsfeedsRouterRulesLegacy implements JComponentRouterRulesInterface
{
/**
* Constructor for this legacy router
*
* @param JComponentRouterAdvanced $router The router this rule
belongs to
*
* @since 3.6
* @deprecated 4.0
*/
public function __construct($router)
{
$this->router = $router;
}
/**
* Preprocess the route for the com_newsfeeds component
*
* @param array &$query An array of URL arguments
*
* @return void
*
* @since 3.6
* @deprecated 4.0
*/
public function preprocess(&$query)
{
}
/**
* Build the route for the com_newsfeeds component
*
* @param array &$query An array of URL arguments
* @param array &$segments The URL arguments to use to assemble
the subsequent URL.
*
* @return void
*
* @since 3.6
* @deprecated 4.0
*/
public function build(&$query, &$segments)
{
// Get a menu item based on Itemid or currently active
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);
if (empty($query['Itemid']))
{
$menuItem = $this->router->menu->getActive();
}
else
{
$menuItem =
$this->router->menu->getItem($query['Itemid']);
}
$mView = empty($menuItem->query['view']) ? null :
$menuItem->query['view'];
$mId = empty($menuItem->query['id']) ? null :
$menuItem->query['id'];
if (isset($query['view']))
{
$view = $query['view'];
if (empty($menuItem) || $menuItem->component !==
'com_newsfeeds' || empty($query['Itemid']))
{
$segments[] = $query['view'];
}
unset($query['view']);
}
// Are we dealing with a newsfeed that is attached to a menu item?
if (isset($query['view'], $query['id']) &&
$mView == $query['view'] && $mId == (int)
$query['id'])
{
unset($query['view'], $query['catid'],
$query['id']);
return;
}
if (isset($view) && ($view === 'category' || $view ===
'newsfeed'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
if ($view === 'newsfeed' &&
isset($query['catid']))
{
$catid = $query['catid'];
}
elseif (isset($query['id']))
{
$catid = $query['id'];
}
$menuCatid = $mId;
$categories = JCategories::getInstance('Newsfeeds');
$category = $categories->get($catid);
if ($category)
{
$path = $category->getPath();
$path = array_reverse($path);
$array = array();
foreach ($path as $id)
{
if ((int) $id === (int) $menuCatid)
{
break;
}
if ($advanced)
{
list($tmp, $id) = explode(':', $id, 2);
}
$array[] = $id;
}
$segments = array_merge($segments, array_reverse($array));
}
if ($view === 'newsfeed')
{
if ($advanced)
{
list($tmp, $id) = explode(':', $query['id'], 2);
}
else
{
$id = $query['id'];
}
$segments[] = $id;
}
}
unset($query['id'], $query['catid']);
}
if (isset($query['layout']))
{
if (!empty($query['Itemid']) &&
isset($menuItem->query['layout']))
{
if ($query['layout'] ==
$menuItem->query['layout'])
{
unset($query['layout']);
}
}
else
{
if ($query['layout'] === 'default')
{
unset($query['layout']);
}
}
}
$total = count($segments);
for ($i = 0; $i < $total; $i++)
{
$segments[$i] = str_replace(':', '-',
$segments[$i]);
}
}
/**
* Parse the segments of a URL.
*
* @param array &$segments The segments of the URL to parse.
* @param array &$vars The URL attributes to be used by the
application.
*
* @return void
*
* @since 3.6
* @deprecated 4.0
*/
public function parse(&$segments, &$vars)
{
$total = count($segments);
for ($i = 0; $i < $total; $i++)
{
$segments[$i] = preg_replace('/-/', ':',
$segments[$i], 1);
}
// Get the active menu item.
$item = $this->router->menu->getActive();
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);
// Count route segments
$count = count($segments);
// Standard routing for newsfeeds.
if (!isset($item))
{
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];
return;
}
// From the categories view, we can only jump to a category.
$id = (isset($item->query['id']) &&
$item->query['id'] > 1) ? $item->query['id'] :
'root';
$categories =
JCategories::getInstance('Newsfeeds')->get($id)->getChildren();
$vars['catid'] = $id;
$vars['id'] = $id;
$found = 0;
foreach ($segments as $segment)
{
$segment = $advanced ? str_replace(':', '-',
$segment) : $segment;
foreach ($categories as $category)
{
if ($category->slug == $segment || $category->alias == $segment)
{
$vars['id'] = $category->id;
$vars['catid'] = $category->id;
$vars['view'] = 'category';
$categories = $category->getChildren();
$found = 1;
break;
}
}
if ($found == 0)
{
if ($advanced)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__newsfeeds')
->where($db->quoteName('catid') . ' = ' .
(int) $vars['catid'])
->where($db->quoteName('alias') . ' = ' .
$db->quote($segment));
$db->setQuery($query);
$nid = $db->loadResult();
}
else
{
$nid = $segment;
}
$vars['id'] = $nid;
$vars['view'] = 'newsfeed';
}
$found = 0;
}
}
}
PK[��[�)`� .DS_Storenu�[���PK[��[{��!����=helpers.phpnu�[���PK[��[�#o,,
q�index.htmlnu�[���PK[��[n?3����version.phpnu�[���PK��[3�,h�� ��route.phpnu�[���PK���[��B��7�7��html/filter.phpnu�[���PK���[��f���html/query.phpnu�[���PKK!�[�
�
� (!blank.phpnu�[���PKK!�[8A+��n�category.phpnu�[���PKK!�[{�]���=�headercheck.phpnu�[���PK�,�[tL�99 W�media.phpnu�[���PK>�[���X����association.phpnu�[���PK>�[�������legacyrouter.phpnu�[���PK
��