Exemple #1
0
 /**
  * create the SQL install file
  * @param object package $row
  */
 protected function makeInstallSQL($row)
 {
     $sql = '';
     $config = JFactory::getConfig();
     $db = FabrikWorker::getDbo(true);
     //create the sql for the cloned fabrik meta data tables
     foreach ($this->tables as $table) {
         $db->setQuery('SHOW CREATE TABLE ' . $table);
         $tbl = $db->loadRow();
         $tbl = str_replace('_fabrik_', '_' . $row->component_name . '_', $tbl[1]);
         $tbl = str_replace($config->get('dbprefix'), '#__', $tbl);
         $sql .= str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $tbl) . ";\n\n";
         $table = str_replace(array('_fabrik_', '{package}'), array('_' . $row->component_name . '_', $row->component_name), $table);
         $sql .= 'TRUNCATE TABLE ' . $table . ";\n\n";
     }
     foreach ($row->blocks as $block => $ids) {
         $key = fabrikString::rtrimword($block, 's');
     }
     // create the sql to build the db tables that store the data.
     $formModel = JModel::getInstance('form', 'FabrikFEModel');
     $lookups = $this->getInstallItems($row);
     $lids = $lookups->list;
     JArrayHelper::toInteger($lids);
     foreach ($lids as $lid) {
         $listModel = JModel::getInstance('list', 'FabrikFEModel');
         $listModel->setId($lid);
         $sql .= "\n\n" . $listModel->getCreateTableSQL(true);
     }
     $plugins = array();
     foreach ($lookups->form as $fid) {
         $formModel->setId($fid);
         if (!in_array($fid, $lookups->list)) {
             $lookups->list[] = $fid;
         }
         //@FIXME get sql to create tables for dbjoin/cdd elements (need to do if not exists)
         $dbs = $formModel->getElementOptions(false, 'name', true, true, array());
     }
     $sql .= "\n\n";
     foreach ($lookups->visualization as $vid) {
         $vrow = FabTable::getInstance('Visualization', 'FabrikTable');
         $vrow->load($vid);
         $visModel = JModel::getInstance($vrow->plugin, 'fabrikModel');
         $visModel->setId($vid);
         $visModel->setListIds();
         $listModels = $visModel->getlistModels();
         foreach ($listModels as $lmodel) {
             $sql .= $lmodel->getCreateTableSQL(true);
             //add the table ids to the $lookups->list
             if (!in_array($lmodel->getId(), $lookups->list)) {
                 $lookups->list[] = $lmodel->getId();
             }
         }
     }
     $path = $this->outputPath . 'admin/sql/install.mysql.uft8.sql';
     JFile::write($path, $sql);
     return $path;
 }
Exemple #2
0
 /**
  * Draws the html form element
  *
  * @param   array  $data           To pre-populate element with
  * @param   int    $repeatCounter  Repeat group counter
  *
  * @return  string	Elements html
  */
 public function render($data, $repeatCounter = 0)
 {
     $name = $this->getHTMLName($repeatCounter);
     $id = $this->getHTMLId($repeatCounter);
     $element = $this->getElement();
     if ($element->hidden == '1') {
         return $this->getHiddenField($name, $this->getValue($data, $repeatCounter), $id);
     }
     $params = $this->getParams();
     $cols = $params->get('width', $element->width);
     $rows = $params->get('height', $element->height);
     $value = $this->getValue($data, $repeatCounter);
     $bits = array();
     $bits['class'] = "fabrikinput inputbox " . $params->get('bootstrap_class');
     $wysiwyg = $this->useWysiwyg();
     if (!$this->isEditable()) {
         if ($params->get('textarea-tagify') == true) {
             $value = $this->tagify($value);
         } else {
             if (!$wysiwyg) {
                 $value = nl2br($value);
             }
             if ($value !== '' && ((int) $params->get('textarea-truncate-where', 0) === 2 || (int) $params->get('textarea-truncate-where', 0) === 3)) {
                 $opts = $this->truncateOpts();
                 $value = fabrikString::truncate($value, $opts);
             }
         }
         return $value;
     }
     if ($params->get('textarea_placeholder', '') !== '') {
         $bits['placeholder'] = $params->get('textarea_placeholder');
     }
     if ($this->elementError != '') {
         $bits['class'] .= ' elementErrorHighlight';
     }
     $layoutData = new stdClass();
     $this->charsLeft($value, $layoutData);
     if ($wysiwyg) {
         $editor = JEditor::getInstance($this->config->get('editor'));
         $buttons = (bool) $params->get('wysiwyg_extra_buttons', true);
         $layoutData->editor = $editor->display($name, $value, $cols * 10, $rows * 15, $cols, $rows, $buttons, $id);
         $layout = $this->getLayout('wysiwyg');
     } else {
         if ($params->get('disable')) {
             $bits['class'] .= " disabled";
             $bits['disabled'] = 'disabled';
         }
         if ($params->get('textarea-showmax') && $params->get('textarea_limit_type', 'char') === 'char') {
             $bits['maxlength'] = $params->get('textarea-maxlength');
         }
         $bits['name'] = $name;
         $bits['id'] = $id;
         $bits['cols'] = $cols;
         $bits['rows'] = $rows;
         $layoutData->attributes = $bits;
         $layoutData->value = $value;
         $layout = $this->getLayout('form');
     }
     return $layout->render($layoutData);
 }
Exemple #3
0
 function truncate($text, $opts = array())
 {
     return fabrikString::truncate($data, $opts);
 }
Exemple #4
0
 /**
  * shows the data formatted for the table view
  * @param string data
  * @param object all the data in the tables current row
  * @return string formatted value
  */
 function renderListData($data, $oAllRowsData)
 {
     $data = parent::renderListData($data, $oAllRowsData);
     $params = $this->getParams();
     if ($params->get('textarea-tagify') == true) {
         $data = $this->tagify($data);
     }
     //$$$rob dont strip slashes here - this is done when saving to db now
     if ($params->get('use_wysiwyg', 0) == 0) {
         if (is_array($data)) {
             for ($i = 0; $i < count($data); $i++) {
                 $data[$i] = nl2br($data[$i]);
             }
         } else {
             if (is_object($data)) {
                 $this->convertDataToString($data);
             }
             $data = nl2br($data);
         }
     }
     if (!$params->get('textarea-tagify') && $data !== '' && (int) $params->get('textarea-truncate', 0) !== 0) {
         $opts = array();
         $opts['wordcount'] = (int) $params->get('textarea-truncate', 0);
         $opts['tip'] = $params->get('textarea-hover');
         $opts['position'] = $params->get('textarea_hover_location', 'top');
         $data = fabrikString::truncate($data, $opts);
     }
     return $data;
 }