Example #1
0
 /**
  * Attach a progress bar to this monitor.
  *
  * @param      object    $bar           a html_progress instance
  *
  * @return     void
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        getProgressElement()
  */
 function setProgressElement($bar)
 {
     if (!is_a($bar, 'HTML_Progress')) {
         return $this->_progress->raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$bar', 'was' => gettype($bar), 'expected' => 'HTML_Progress object', 'paramnum' => 1));
     }
     $this->_progress = $bar;
     $bar =& $this->_form->getElement('progressBar');
     $bar->setText($this->_progress->toHtml());
 }
Example #2
0
 /**
  * Attach a progress bar to this monitor.
  *
  * @param      object    $bar           a html_progress instance
  *
  * @return     void
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        getProgressElement()
  */
 function setProgressElement($bar)
 {
     if (!is_a($bar, 'HTML_Progress')) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$bar', 'was' => gettype($bar), 'expected' => 'HTML_Progress object', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     }
     $this->_progress = $bar;
     $this->_progress->addListener($this);
     $bar =& $this->_form->getElement('progressBar');
     $bar->setText($this->_progress->toHtml());
 }
Example #3
0
 /**
  * Attach a progress bar to this uploader.
  *
  * @param      object    $bar           a html_progress instance
  *
  * @return     void
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function setProgressElement(&$bar)
 {
     if (!is_a($bar, 'HTML_Progress')) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$bar', 'was' => gettype($bar), 'expected' => 'HTML_Progress object', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     }
     $this->_progress =& $bar;
     $this->_progress->setStringPainted(true);
     // get space for the string
     $this->_progress->setString("");
     // but don't paint it
     $this->_progress->setIndeterminate(true);
     $bar =& $this->_form->getElement('progressBar');
     $bar->setText($this->_progress->toHtml());
 }
Example #4
0
/**
 * Will attempt to get the element for the posted key
 *
 * @param   object  $formModel  Form model
 * @param   string  $key        POST key value
 *
 * @return  array(label, is the key a raw element, should we show the element)
 */
function tryForLabel($formModel, $key, $raw, $info)
{
    $elementModel = $formModel->getElement($key);
    $label = $key;
    $thisRaw = false;
    if ($elementModel) {
        $label = $elementModel->getElement()->label;
    } else {
        if (substr($key, -4) == '_raw') {
            $thisRaw = true;
            $key = substr($key, 0, strlen($key) - 4);
            $elementModel = $formModel->getElement($key);
            if ($elementModel) {
                $label = $elementModel->getElement()->label . ' (raw)';
            }
        }
    }
    $show = true;
    if ($thisRaw && !$raw || !$elementModel && !$info) {
        $show = false;
    }
    return array($label, $thisRaw, $show);
}
Example #5
0
 /**
  * LiveUser_Auth_Container_XML::_updateUserData()
  *
  * Writes current values for user back to the database.
  * This method does nothing in the base class and is supposed to
  * be overridden in subclasses according to the supported backend.
  *
  * @access private
  */
 function _updateUserData()
 {
     if (!$this->init_ok || !$this->userObj) {
         return false;
     }
     $data = array('lastLogin' => $this->currentLogin);
     $index = 0;
     foreach ($this->userObj->children as $value) {
         if (in_array($value->name, array_keys($data))) {
             $el =& $this->userObj->getElement(array($index));
             $el->setContent($data[$value->name]);
         }
         $index++;
     }
     $success = false;
     do {
         $fp = fopen($this->file, 'wb');
         if (!$fp) {
             $errorMsg = "Auth freeze failure. Failed to open the xml file.";
             break;
         }
         if (!flock($fp, LOCK_EX)) {
             $errorMsg = "Auth freeze failure. Couldn't get an exclusive lock on the file.";
             break;
         }
         if (!fwrite($fp, $this->tree->get())) {
             $errorMsg = "Auth freeze failure. Write error when writing back the file.";
             break;
         }
         @fflush($fp);
         $success = true;
     } while (false);
     @flock($fp, LOCK_UN);
     @fclose($fp);
     if (!$success) {
         return LiveUser::raiseError(LIVEUSER_ERROR, null, null, $errorMsg);
     }
     return $success;
 }
Example #6
0
 /**
  * upload and move the file if valid to the uploaded directory
  *
  * @param object $page       the CRM_Core_Form object
  * @param object $data       the QFC data container
  * @param string $pageName   the name of the page which index the data container with
  * @param string $uploadName the name of the uploaded file
  *
  * @return void
  * @access private
  */
 function upload(&$page, &$data, $pageName, $uploadName)
 {
     if (empty($uploadName)) {
         return;
     }
     // get the element containing the upload
     $element =& $page->getElement($uploadName);
     if ('file' == $element->getType()) {
         if ($element->isUploadedFile()) {
             // rename the uploaded file with a unique number at the end
             $value = $element->getValue();
             $newName = uniqid("{$value['name']}.");
             $status = $element->moveUploadedFile($this->_uploadDir, $newName);
             if (!$status) {
                 CRM_Utils_System::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the CIVICRM_IMAGE_UPLOADDIR setting points to a valid path which is writable by your web server.', array(1 => $value['name'], 2 => $this->_uploadDir)));
             }
             if (!empty($data['values'][$pageName][$uploadName])) {
                 @unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]);
             }
             $data['values'][$pageName][$uploadName] = $this->_uploadDir . $newName;
         }
     }
 }
Example #7
0
 /**
  * DB_DataObject_FormBuilder_QuickForm::_freezeFormElements()
  *
  * Freezes a list of form elements (set read-only).
  * Used in _generateForm().
  *
  * @param object $form               The form object in question
  * @param array  $elements_to_freeze List of element names to be frozen
  * @access protected
  * @see DB_DataObject_FormBuilder::_generateForm()
  */
 function _freezeFormElements(&$form, $elementsToFreeze)
 {
     foreach ($elementsToFreeze as $elementToFreeze) {
         $elementToFreeze = $this->getFieldName($elementToFreeze);
         if ($form->elementExists($elementToFreeze)) {
             $el =& $form->getElement($elementToFreeze);
             $el->freeze();
         }
     }
 }
Example #8
0
 /**
  * called at the end of saving an element
  * if a new element it will run the sql to add to field,
  * if existing element and name changed will create query to be used later
  * @param object $elementModel
  * @param string $origColName
  * @return array($update, $q, $oldName, $newdesc, $origDesc, $dropKey)
  */
 public function shouldUpdateElement(&$elementModel, $origColName = null)
 {
     $db = FabrikWorker::getDbo();
     $return = array(false, '', '', '', '', false);
     $element =& $elementModel->getElement();
     $pluginManager =& $this->getPluginManager();
     $basePlugIn =& $pluginManager->getPlugIn($element->plugin, 'element');
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     $fabrikDb = $this->getDb();
     $group =& $elementModel->getGroup();
     $dropKey = false;
     //$$$ rob - replaced this with getting the table from the group as if we moved the element
     //from one group to another $this->getTable gives you the old group's table, where as we want
     // the new group's table
     //$table 			=& $this->getTable();
     $table =& $group->getlistModel()->getTable();
     // $$$ rob - if we are saving an element that wasn't attached to a group then we should
     // get the table id from the group's table
     if ($table->id == '') {
         $table =& $group->getlistModel()->getTable();
     }
     // $$$ hugh - if this is a table-less form ... not much point going any
     // further 'cos things will go BANG
     if (empty($table->id)) {
         return $return;
     }
     if ($this->isView()) {
         return $return;
     }
     if ($group->isJoin()) {
         $tableName = $group->getJoinModel()->getJoin()->table_join;
         $keydata = $keydata[0];
         $primaryKey = $keydata['colname'];
     } else {
         $tableName = $table->db_table_name;
         $primaryKey = $table->db_primary_key;
     }
     $keydata = $this->getPrimaryKeyAndExtra($tableName);
     // $$$ rob base plugin needs to know group info for date fields in non-join repeat groups
     $basePlugIn->_group =& $elementModel->_group;
     $objtype = $elementModel->getFieldDescription();
     //the element type AFTER saving
     $dbdescriptions = $this->getDBFields($tableName, 'Field');
     if (!$this->canAlterFields()) {
         $objtype = $dbdescriptions[$origColName]->Type;
     }
     if (is_null($objtype)) {
         return $return;
     }
     $existingfields = array_keys($dbdescriptions);
     $lastfield = $existingfields[count($existingfields) - 1];
     $tableName = FabrikString::safeColName($tableName);
     $lastfield = FabrikString::safeColName($lastfield);
     $altered = false;
     if (!array_key_exists($element->name, $dbdescriptions)) {
         if ($origColName == '') {
             $fabrikDb->setQuery("ALTER TABLE {$tableName} ADD COLUMN " . FabrikString::safeColName($element->name) . " {$objtype} AFTER {$lastfield}");
             if (!$fabrikDb->query()) {
                 return JError::raiseError(500, 'alter structure: ' . $fabrikDb->getErrorMsg());
             }
             $altered = true;
         }
         // commented out as it stops the update when changing an element name
         //return $return;
     }
     $thisFieldDesc = JArrayHelper::getValue($dbdescriptions, $origColName, new stdClass());
     // $$$ rob the Default property for timestamps when they are set to CURRENT_TIMESTAMP
     // doesn't show up from getDBFields()  - so presuming a timestamp field will always default
     // to the current timestamp (update of the field's data controller in the Extra property (on update CURRENT_TIMESTAMP)
     $existingDef = '';
     if (isset($thisFieldDesc->Type)) {
         $existingDef = $thisFieldDesc->Type;
         if ($thisFieldDesc->Type == 'timestamp') {
             $existingDef .= $thisFieldDesc->Null = 'YES' ? ' NULL' : ' NOT NULL';
             $existingDef .= ' DEFAULT CURRENT_TIMESTAMP';
             $existingDef .= ' ' . $thisFieldDesc->Extra;
         }
     }
     //if its the primary 3.0
     for ($k = 0; $k < count($keydata); $k++) {
         if ($keydata[$k]['colname'] == $origColName) {
             $existingDef .= " " . $keydata[$k]['extra'];
         }
     }
     if (!is_null($objtype)) {
         $lowerobjtype = strtolower(trim($objtype));
         $lowerobjtype = str_replace(' not null', '', $lowerobjtype);
         if ($element->name == $origColName && strtolower(trim($existingDef)) == $lowerobjtype) {
             //no chanages to the element name or field type
             return $return;
         }
         $return[4] = $existingDef;
         $existingfields = array_keys($dbdescriptions);
         $lastfield = $existingfields[count($existingfields) - 1];
         $element->name = FabrikString::safeColName($element->name);
         $tableName = FabrikString::safeColName($tableName);
         $lastfield = FabrikString::safeColName($lastfield);
         // $$$ rob this causes issues when renaming an element with the same name but different upper/lower case
         //if (empty($origColName) || !in_array(strtolower($origColName ), $existingfields)) {
         if (empty($origColName) || !in_array($origColName, $existingfields)) {
             if (!$altered) {
                 $fabrikDb->setQuery("ALTER TABLE {$tableName} ADD COLUMN {$element->name} {$objtype} AFTER {$lastfield}");
                 if (!$fabrikDb->query()) {
                     return JError::raiseError(500, 'alter structure: ' . $fabrikDb->getErrorMsg());
                 }
             }
         } else {
             // $$$ rob don't alter it yet - lets defer this and give the user the choice if they
             // really want to do this
             if ($this->canAlterFields()) {
                 if ($origColName == null) {
                     $origColName = $element->name;
                 } else {
                     $origColName = $fabrikDb->nameQuote($origColName);
                 }
                 if (strtolower($objtype) == 'blob') {
                     $dropKey = true;
                 }
                 $q = "ALTER TABLE {$tableName} CHANGE {$origColName} {$element->name} {$objtype} ";
                 if ($primaryKey == $fabrikDb->NameQuote($tableName) . "." . $element->name && $table->auto_inc) {
                     if (!strstr($q, 'NOT NULL AUTO_INCREMENT')) {
                         $q .= " NOT NULL AUTO_INCREMENT ";
                     }
                 }
                 $origColName = FabrikString::safeColName($origColName);
                 $return[0] = true;
                 $return[1] = $q;
                 $return[2] = $origColName;
                 $return[3] = $objtype;
                 $return[5] = $dropKey;
                 return $return;
             }
         }
     }
     return $return;
 }
Example #9
0
 /**
  * get the data map to transform web service data into list data
  * @param	object	$formModel
  * @return	array	data map
  */
 protected function getMap($formModel)
 {
     $params = $this->getParams();
     $map = json_decode($params->get('webservice_map'));
     $return = array();
     $from = $map->map_from;
     $to = $map->map_to;
     $match = $map->map_match;
     $value = $map->map_value;
     $eval = $map->map_eval;
     $n = count($from);
     for ($i = 0; $i < $n; $i++) {
         $tid = $formModel->getElement($to[$i], true)->getElement()->name;
         $return[] = array('from' => $from[$i], 'to' => $tid, 'value' => $value[$i], 'match' => $match[$i], 'eval' => (bool) $eval[$i]);
     }
     return $return;
 }
Example #10
0
 /**
  * Get the name of the repeated elements table
  *
  * @param   object $elementModel element model
  * @param   object $row          element item
  *
  * @return  string    table name
  */
 protected function getRepeatElementTableName($elementModel, $row = null)
 {
     $listModel = $elementModel->getListModel();
     $groupModel = $elementModel->getGroupModel();
     if (is_null($row)) {
         $row = $elementModel->getElement();
     }
     if ($groupModel->isJoin()) {
         $origTableName = $groupModel->getJoinModel()->getJoin()->table_join;
     } else {
         $origTableName = $listModel->getTable()->db_table_name;
     }
     return $origTableName . '_repeat_' . str_replace('`', '', $row->name);
 }
Example #11
0
    /**
     * Add the input areas for each unit.
     * @param object $mform the form being built.
     */
    protected function add_unit_fields($mform) {
        $repeated = array(
            $mform->createElement('header', 'unithdr',
                    get_string('unithdr', 'qtype_numerical', '{no}')),
            $mform->createElement('text', 'unit', get_string('unit', 'quiz')),
            $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')),
        );

        $repeatedoptions['unit']['type'] = PARAM_NOTAGS;
        $repeatedoptions['multiplier']['type'] = PARAM_NUMBER;
        $repeatedoptions['unit']['disabledif'] =
                array('unitrole', 'eq', qtype_numerical::UNITNONE);
        $repeatedoptions['multiplier']['disabledif'] =
                array('unitrole', 'eq', qtype_numerical::UNITNONE);

        if (isset($this->question->options->units)) {
            $countunits = count($this->question->options->units);
        } else {
            $countunits = 0;
        }
        if ($this->question->formoptions->repeatelements) {
            $repeatsatstart = $countunits + 1;
        } else {
            $repeatsatstart = $countunits;
        }
        $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'nounits',
                'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));

        if ($mform->elementExists('multiplier[0]')) {
            $firstunit = $mform->getElement('multiplier[0]');
            $firstunit->freeze();
            $firstunit->setValue('1.0');
            $firstunit->setPersistantFreeze(true);
            $mform->addHelpButton('multiplier[0]', 'numericalmultiplier', 'qtype_numerical');
        }
    }
Example #12
0
 /**
  * Get the name of the repeated elements table
  *
  * @param   object  $elementModel  element model
  * @param   object  $row           element item
  *
  * @return  string	table name
  */
 protected function getRepeatElementTableName($elementModel, $row = null)
 {
     $listModel = $elementModel->getListModel();
     if (is_null($row)) {
         $row = $elementModel->getElement();
     }
     $origTableName = $listModel->getTable()->db_table_name;
     return $origTableName . '_repeat_' . str_replace('`', '', $row->name);
 }
Example #13
0
 /**
  * Get the href for the edit/details link
  *
  * @param   object  $elementModel   Element model
  * @param   array   $row            Lists current row data
  * @param   int     $repeatCounter  Repeat group counter
  *
  * @since   2.0.4
  *
  * @return  string	link href
  */
 public function linkHref($elementModel, $row, $repeatCounter = 0)
 {
     $element = $elementModel->getElement();
     $table = $this->getTable();
     $params = $elementModel->getParams();
     $customLink = $params->get('custom_link');
     $link = '';
     if ($customLink == '') {
         // $$$ rob only test canEdit and canView on standard edit links - if custom we should always use them,
         // 3.0 get either edit or view link - as viewDetailsLink now always returns the view details link
         if ($this->canEdit($row)) {
             $this->_aLinkElements[] = $element->name;
             $link = $this->editLink($row);
         } elseif ($this->canViewDetails($row)) {
             $this->_aLinkElements[] = $element->name;
             $link = $this->viewDetailsLink($row);
         }
     } else {
         $array = ArrayHelper::fromObject($row);
         foreach ($array as $k => &$v) {
             /* $$$ hugh - not everything is JSON, some stuff is just plain strings.
              * So we need to see if JSON encoding failed, and only use result if it didn't.
              * $v = json_decode($v, true);
              */
             if (is_array($v)) {
                 $v = FArrayHelper::getValue($v, $repeatCounter);
             } else {
                 $v2 = json_decode($v, true);
                 if ($v2 !== null) {
                     if (is_array($v2)) {
                         $v = FArrayHelper::getValue($v2, $repeatCounter);
                     } else {
                         $v = $v2;
                     }
                 }
             }
         }
         $array['rowid'] = $this->getSlug($row);
         $array['listid'] = $table->id;
         $link = JRoute::_($this->parseMessageForRowHolder($customLink, $array));
     }
     // Allow creating custom links, default layout will just return $link unaltered
     $layout = FabrikHelperHTML::getLayout('element.fabrik-element-details-link');
     $displayData = new stdClass();
     $displayData->row = $row;
     $displayData->listModel = $this;
     $displayData->elementModel = $elementModel;
     $displayData->customLink = $customLink;
     $displayData->repeatCounter = $repeatCounter;
     $displayData->link = $link;
     $link = $layout->render($displayData);
     return $link;
 }
Example #14
0
 /**
  * Insert individual querystring filter into filter array
  *
  * @param   object  $elementModel  element model
  * @param   array   &$filters      filter array
  * @param   mixed   $value         value
  * @param   string  $condition     condition
  * @param   string  $join          join
  * @param   bool    $grouped       is grouped
  * @param   bool    $eval          is eval
  * @param   string  $key           element key
  * @param   bool    $raw           is the filter a raw filter (tablename___elementname_raw=foo)
  *
  * @return  void
  */
 private function indQueryString($elementModel, &$filters, $value, $condition, $join, $grouped, $eval, $key, $raw = false)
 {
     $input = $this->app->input;
     $element = $elementModel->getElement();
     $elParams = $elementModel->getParams();
     if (is_string($value)) {
         $value = trim($value);
     }
     $k2 = FabrikString::safeColNameToArrayKey($key);
     /**
      * $$$ rob fabrik_sticky_filters set in J content plugin
      * Treat these as prefilters so we don't unset them
      * when we clear the filters
      */
     $stickyFilters = $input->get('fabrik_sticky_filters', array(), 'array');
     $filterType = in_array($k2 . '_raw', $stickyFilters) || in_array($k2, $stickyFilters) ? 'jpluginfilters' : 'querystring';
     $filters['value'][] = $value;
     $filters['condition'][] = urldecode($condition);
     $filters['join'][] = $join;
     $filters['no-filter-setup'][] = $element->filter_type == '' ? 1 : 0;
     $filters['hidden'][] = $element->filter_type == '' ? 1 : 0;
     $filters['key'][] = $key;
     $filters['key2'][] = '';
     $filters['search_type'][] = $filterType;
     $filters['match'][] = $element->filter_exact_match;
     $filters['full_words_only'][] = $elParams->get('full_words_only');
     $filters['eval'][] = $eval;
     $filters['required'][] = $elParams->get('filter_required');
     $filters['access'][] = $elParams->get('filter_access');
     $filters['grouped_to_previous'][] = $grouped;
     $filters['label'][] = $elementModel->getListHeading();
     $filters['elementid'][] = $element->id;
     $filters['raw'][] = $raw;
 }
Example #15
0
 /**
  * Test if the notifications should be fired
  *
  * @param   object  $formModel  form model
  * @param   JRegistry  $params  params
  *
  * @return  bool
  */
 protected function triggered($formModel, $params)
 {
     if ($params->get('send_mode', 0) == 0) {
         $user = JFactory::getUser();
         return $user->get('id') == 0 ? false : true;
     } else {
         $triggerEl = $formModel->getElement($params->get('trigger'), true);
         $trigger = $triggerEl->getFullName();
         $data = $formModel->getData();
         return JArrayHelper::getValue($data, $trigger) == $params->get('trigger_value') ? true : false;
     }
 }
 /**
  * Custom validation method
  * This is executed AFTER form submit
  * Main validation is handled by adding rules to the form in buildForm()
  * which are processed prior to this method being called
  *
  * @param object $form
  * @return boolean
  */
 function validateForm(&$form)
 {
     if ($form->isSubmitted()) {
         $errors = array();
         foreach ($this->requiredElement as $requiredElement) {
             $fieldName = $requiredElement[0];
             $fieldNameWhenRequired = $requiredElement[1];
             $fieldValueWhenRequired = $requiredElement[2];
             $fieldValueWhenRequiredSubmittedValue = $form->getSubmitValue($fieldNameWhenRequired);
             if ($fieldValueWhenRequiredSubmittedValue == $fieldValueWhenRequired) {
                 $submittedValue = $form->getSubmitValue($fieldName);
                 if (empty($submittedValue)) {
                     $errors[] = $this->getFieldLabel($fieldName);
                 }
             }
         }
         if (count($errors) == 0) {
             if ($form->getSubmitValue('vast_video_type') != 'video/webm' || $form->getSubmitValue('vast_video_delivery') == 'progressive') {
                 $form->removeElement('video_form_error');
                 return true;
             } else {
                 $errorString = 'WEBM video type is not compatible with streaming delivery';
             }
         } else {
             $errorString = 'Please provide values for all required fields: <ul><li>';
             $errorString .= implode('</li><li>', $errors);
             $errorString .= '</li></ul>';
         }
         $form->getElement('video_form_error')->setText(VideoAdsHelper::getErrorMessage($errorString));
         return false;
     }
     return true;
 }
Example #17
0
 /**
  * Sets up HTML to be injected into the form's bottom
  *
  * @param   object  $params     params
  * @param   object  $formModel  form model
  *
  * @return void
  */
 public function getBottomContent($params, $formModel)
 {
     // If we have already processed the form
     $this->html = '';
     if (JRequest::getVar('fabrik_confirmation') == 1) {
         $session = JFactory::getSession();
         // Unset this flag
         JRequest::setVar('fabrik_confirmation', 2);
         $post = JRequest::get('post', 4);
         /**
          * load in the posted values as hidden fields so that if we
          * return to the form to edit it it will populate with our data
          */
         // $$$ 24/10/2011 testing removing this as data is retrieved via the session not thorugh posted data
         foreach ($post as $key => $val) {
             $noneraw = JString::substr($key, 0, JString::strlen($key) - 4);
             if ($key == 'join' || $key == 'fabrik_vars') {
                 continue;
             }
             if ($formModel->hasElement($key) || $formModel->hasElement($noneraw)) {
                 // Return;
             }
             if ($formModel->hasElement($noneraw)) {
                 $key = $formModel->getElement($noneraw)->getHTMLName(0);
                 // $$$ rob include both raw and non-raw keys (non raw for radios etc, _raw for db joins)
                 if (is_array($val)) {
                     foreach ($val as $val2) {
                         if (!FabrikWorker::isReserved($key)) {
                             if (!strstr($key, '[]')) {
                                 $key .= '[]';
                             }
                             // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'[]" value="'.urlencode($val2).'" />';
                             // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val2).'" />';
                             $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val2 . '" />';
                         }
                     }
                 } else {
                     if (!FabrikWorker::isReserved($key)) {
                         // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'" value="'.urlencode($val).'" />';
                         // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val).'" />';
                         $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
                     }
                 }
             }
         }
         // Add in a view field as the form doesn't normally contain one
         $fields[] = '<input type="hidden" name="view" value="form" />';
         $fields[] = '<input type="hidden" name="fabrik_confirmation" value="2" />';
         // Add in a button to allow you to go back to the form and edit your data
         $fields[] = "<input type=\"button\" id=\"fabrik_redoconfirmation\" class=\"button\" value=\"" . JText::_('PLG_FORM_CONFIRMATION_RE_EDIT') . "\" />";
         // Unset the task otherwise we will submit the form to be processed.
         FabrikHelperHTML::addScriptDeclaration("head.ready(function() {" . "\$('fabrik_redoconfirmation').addEvent('click', function(e) {;\n" . "  this.form.task.value = '';\n" . "  this.form.submit.click();\n" . "\t});\n" . "});");
         $this->html = implode("\n", $fields);
     }
 }
Example #18
0
 /**
  * Get the Address data
  *
  * @param object $address The Address Object
  * 
  * @return array The data
  */
 public function getAddressData($address)
 {
     $billing_info = $this->getBillingInfo();
     $result = array();
     foreach ($billing_info as $key => $info) {
         if ($key == 'country') {
             $result[$key] = array_shift($address->getElement($info)->get('country'));
         } else {
             $value = $address->getElement($info)->data();
             while (is_array($value)) {
                 $value = array_shift($value);
             }
             $result[$key] = $value;
         }
     }
     return $result;
 }
Example #19
-1
 /**
  * upload and move the file if valid to the uploaded directory
  *
  * @param object $page       the CRM_Core_Form object
  * @param object $data       the QFC data container
  * @param string $pageName   the name of the page which index the data container with
  * @param string $uploadName the name of the uploaded file
  *
  * @return void
  * @access private
  */
 function upload(&$page, &$data, $pageName, $uploadName)
 {
     // make sure uploadName exists in the QF array
     // else we skip, CRM-3427
     if (empty($uploadName) || !isset($page->_elementIndex[$uploadName])) {
         return;
     }
     // get the element containing the upload
     $element =& $page->getElement($uploadName);
     if ('file' == $element->getType()) {
         if ($element->isUploadedFile()) {
             // rename the uploaded file with a unique number at the end
             $value = $element->getValue();
             $newName = CRM_Utils_File::makeFileName($value['name']);
             $status = $element->moveUploadedFile($this->_uploadDir, $newName);
             if (!$status) {
                 CRM_Core_Error::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the \'Temporary Files\' setting points to a valid path which is writable by your web server.', array(1 => $value['name'], 2 => $this->_uploadDir)));
             }
             if (!empty($data['values'][$pageName][$uploadName]['name'])) {
                 @unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]);
             }
             $data['values'][$pageName][$uploadName] = array('name' => $this->_uploadDir . $newName, 'type' => $value['type']);
         }
     }
 }