Example #1
0
 public function getItem($id = 'en-GB', $refresh = false, $emptyState = true)
 {
     if (empty($this->_item)) {
         $lang = JLanguage::getInstance($id);
         // Load only site language (Email language costants should be only there)
         $lang->load('com_citruscart', JPATH_ADMINISTRATOR, $id, true);
         $temp_paths = $lang->getPaths('com_citruscart');
         foreach ($temp_paths as $p => $k) {
             $path = $p;
         }
         $result = new JObject();
         $result->name = $lang->getName();
         $result->code = $lang->getTag();
         $result->path = $path;
         $result->strings = array();
         // Load File and Take only the constants that contains "EMAIL_"
         $file = new DSCParameter();
         $file->loadFile($path);
         $strings = $file->toArray();
         $result_strings = array();
         foreach ($strings as $k => $v) {
             // Only if it is a prefix!
             if (stripos($k, $this->email_prefix) === 0) {
                 $result_strings[$k] = $v;
             }
         }
         $result->strings = array('file' => $path, 'strings' => $result_strings);
         JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$result));
         $this->_item = $result;
     }
     return $this->_item;
 }
Example #2
0
 /**
  * 
  * Retrieves a product's custom fields from the product_params column
  * in as an array of CustomField objects so that the rendering of the
  * custom fields can be on typed objects. 
  * @param $product_id
  */
 function getCustomFields($product_id)
 {
     if (empty($product_id)) {
         return array();
     }
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('Products', 'TiendaModel');
     $model->setId($product_id);
     $item = $model->getItem();
     if (empty($item)) {
         return null;
     }
     $product_param = new DSCParameter(trim($item->product_params));
     //todo: remove the items that are not custom fields
     if (empty($product_param)) {
         return array();
     }
     $params = $product_param->toArray();
     $custom_fields = null;
     foreach ($params as $key => $value) {
         if (strpos($key, 'custom_field') !== false) {
             if ($custom_fields == null) {
                 $custom_fields = array();
             }
             $custom_field = array();
             $field_properties = explode(",", $value);
             foreach ($field_properties as $field_property) {
                 $property_pair = explode(":", $field_property);
                 if (!empty($property_pair)) {
                     $custom_field[trim($property_pair[0])] = trim($property_pair[1]);
                 }
             }
             $custom_field["id"] = $key;
             array_push($custom_fields, (object) $custom_field);
         }
     }
     return $custom_fields;
 }