public function toHTML() { // change to facilitate lists $id = 'search_' . $this->fieldname; $name = 'Search[' . $this->fieldname . ']'; if (count($this->options) > get_config('AUTOCOMPLETE_SELECT_LIMIT')) { $html = ''; $selected = $this->value; if (empty($selected)) { $selected = $this->default; } $html .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . $selected . '" />'; $text_value = isset($this->options[$selected]) ? $this->options[$selected] : ''; $html .= '<input alt="Autocomplete enabled" type="text" id="' . $id . '_text" value="' . $text_value . '" class="uz-autocomplete ui-autocomplete-input icon slim" data-id="' . $id . '" data-action="array" />'; $html .= '<script type="text/javascript">' . 'var ' . $id . '=' . json_encode(dataObject::toJSONArray($this->options)) . '</script>'; } else { $html = '<select id="' . $id . '" name="' . $name . '">'; foreach ($this->options as $val => $opt) { $selected = ''; if ($this->value === "{$val}" || is_null($this->value) && $this->default === "{$val}") { $selected = 'selected="selected"'; } $html .= '<option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>'; } $html .= '</select></li>'; } return $this->labelHTML() . $html; }
public function __construct($page_path) { $conn = dataObject::connect(); $sql = "select articleID,page_no,language,file_size,file_name,file_path from pages where file_path= :file_path;"; try { $st = $conn->prepare($sql); $st->bindValue(":file_path", $page_path, PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); if ($row) { list($this->articleID, $this->page_no, $this->language, $this->file_size, $this->file_name, $this->file_path) = $row; } } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to retrieve page:" . $e->getMessage()); } }
public static function browseArticle(array $filterValues) { $title = $filterValues['title']; $author = $filterValues['author']; $year = $filterValues['year']; $conn = dataObject::connect(); $sql = "select * from authors natural join author_article natural join articles"; if ($author || $title || $year) { $sql .= " where"; } $count = 0; if ($author) { $sql .= " authors.name like :author"; if ($title || $year) { $sql .= " and"; } } if ($title) { $sql .= " articles.title like :title"; if ($year) { $sql .= " and"; } } if ($year) { $sql .= " year= :year"; } $sql .= ';'; try { $st = $conn->prepare($sql); if ($author) { $st->bindValue(":author", $author, PDO::PARAM_STR); } if ($year) { $st->bindValue(":year", $year, PDO::PARAM_INT); } if ($title) { $st->bindValue(":title", $title, PDO::PARAM_STR); } $st->execute(); return $st->fetchAll(); } catch (PDOException $e) { dataObject::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function submitTranslation($translated_content, $page_path) { $ourPage = new Page($page_path); //remove first entry from queue csv $queueHandle = fopen("../pages/pageQueue.csv", 'r'); $currpage = fgetcsv($queueHandle); $newQueue = fopen("../pages/pageQueue2.csv", 'w'); while ($record = fgetcsv($queueHandle)) { fputcsv($newQueue, $record); } fclose($queueHandle); fclose($newQueue); chmod("../pages/pageQueue.csv", 0777); unlink("../pages/pageQueue.csv"); rename("../pages/pageQueue2.csv", "../pages/pageQueue.csv"); //save new page in directory $pagehandle = fopen("../translatedPages/{$ourPage->getFileName()}_translated.txt", 'w'); fwrite($pagehandle, $translated_content); fclose($pagehandle); //make entry into database $conn = dataObject::connect(); $sql = "insert into pages(articleID,page_no,language,file_name,file_size,file_path) values( :articleID, :page_no," . '"hindi",' . ":file_name, :file_size, :file_path);"; try { $st = $conn->prepare($sql); $st->bindValue(":articleID", $ourPage->getarticleID(), PDO::PARAM_INT); $st->bindValue(":page_no", $ourPage->getpageNo(), PDO::PARAM_INT); $st->bindValue(":file_name", "{$ourPage->getFileName()}_translated.txt", PDO::PARAM_STR); $st->bindValue(":file_size", filesize("../translatedPages/{$ourPage->getFileName()}_translated.txt"), PDO::PARAM_STR); $st->bindValue(":file_path", realpath("../translatedPages/{$ourPage->getFileName()}_translated.txt"), PDO::PARAM_STR); $st->execute(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to add page:" . $e->getMessage()); } dataObject::disconnect($conn); }
public function updatePaperDetails($title, $newTitle, $newLanguage, $newYear) { $conn = dataObject::connect(); $sql = "update articles set title= :newtitle, year= :year, language= :language where title= :title;"; try { $st = $conn->prepare($sql); $st->bindValue(':newtitle', $newTitle, PDO::PARAM_STR); $st->bindValue(':title', $title, PDO::PARAM_STR); $st->bindValue(':language', $newLanguage, PDO::PARAM_STR); $st->bindValue(':year', $newYear, PDO::PARAM_INT); $st->execute(); } catch (PDOException $e) { dataObject::disconnect($conn); die("Query failed:" . $e->getMessage()); } }
public static function retrieveUnpublished() { $articleArray = array(); $sql = "select Title,no_of_pages from articles where no_of_translations = 0 and no_of_pages > 0"; try { $conn = dataObject::connect(); $st = $conn->prepare($sql); $st->execute(); $rows = $st->fetchAll(); dataObject::disconnect($conn); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to retrieve articles:" . $e->getMessage()); } $sql = "select count(*) as number from articles join pages on articles.articleID=pages.articleID where articles.Title= :title and pages.language= :language"; $st = $conn->prepare($sql); $st->bindValue(":language", 'hindi', PDO::PARAM_STR); foreach ($rows as $row) { $st->bindValue(":title", $row['Title'], PDO::PARAM_STR); $st->execute(); $num = $st->fetch(); if ($num['number'] == $row['no_of_pages']) { $articleArray[] = $row['Title']; } } return $articleArray; }
function dataedit() { //$this->datasis->modulo_id(101,1); $this->rapyd->load('dataobject', 'dataedit'); $do = new dataObject("ocompra"); $edit = new DataEdit($this->t**s, $do); $do->set('fechapago', date('Y-m-d')); $edit->back_url = site_url($this->url . "filteredgrid"); $edit->pre_process('update', '_valida'); $edit->post_process('update', '_post'); $edit->odirect = new inputField("Numero O. Pago", "odirect"); $edit->odirect->mode = "autohide"; $edit->odirect->group = "Pago"; $edit->fechapago = new dateonlyField("Fecha de Pago", "fechapago"); $edit->fechapago->size = 12; $edit->fechapago->rule = "required"; $edit->fechapago->group = "Pago"; $edit->factura = new inputField("Factura", "factura"); $edit->factura->mode = "autohide"; $edit->factura->group = "Causación"; $edit->controlfac = new inputField("Control Fiscal", "controlfac"); $edit->controlfac->mode = "autohide"; $edit->controlfac->group = "Causación"; $edit->fechafac = new inputField("Fecha Causación", "fechafac"); $edit->fechafac->mode = "autohide"; $edit->fechafac->group = "Causación"; $edit->numero = new inputField("Número O. Compra", "numero"); $edit->numero->mode = "autohide"; $edit->numero->when = array('show'); $edit->numero->group = "Orden De Compra"; $edit->tipo = new inputField("Orden de", "tipo"); $edit->tipo->mode = "autohide"; $edit->tipo->group = "Orden De Compra"; $edit->fecha = new inputField("Fecha O. Compra", "fecha"); $edit->fecha->mode = "autohide"; $edit->fecha->group = "Orden De Compra"; $grupo = 'Datos'; $edit->uejecutora = new inputField("Unidad Ejecutora", "uejecutora"); $edit->uejecutora->mode = "autohide"; $edit->uejecutora->group = $grupo; $edit->estadmin = new dropdownField("Estructura Administrativa", "estadmin"); $edit->estadmin->mode = "autohide"; $edit->estadmin->group = $grupo; $edit->fondo = new dropdownField("Fondo", "fondo"); $edit->fondo->mode = "autohide"; $edit->fondo->group = $grupo; $edit->cod_prov = new inputField("Beneficiario", 'cod_prov'); $edit->cod_prov->size = 6; $edit->cod_prov->group = $grupo; $edit->cod_prov->mode = "autohide"; $edit->nombre = new inputField("Nombre Beneficiario", 'nombre'); $edit->nombre->size = 50; $edit->nombre->group = $grupo; $edit->nombre->mode = "autohide"; $edit->beneficiario = new inputField("Beneficiario", 'beneficiario'); $edit->beneficiario->size = 50; $edit->beneficiario->mode = "autohide"; $edit->beneficiario->group = $grupo; //$edit->beneficiario->rule = "required"; $edit->observa = new textAreaField("Observaciones", 'observa'); $edit->observa->mode = "autohide"; $edit->observa->group = $grupo; $edit->reteiva_prov = new inputField("Retencion IVA Beneficiario", "reteiva_prov"); $edit->reteiva_prov->mode = "autohide"; $edit->reteiva_prov->group = "Retención Iva"; $edit->reteiva = new inputField("Retencion de IVA", 'reteiva'); $edit->reteiva->size = 8; $edit->reteiva->mode = "autohide"; $edit->reteiva->group = "Retención Iva"; $edit->creten = new inputField("Codigo ISLR", "creten"); $edit->creten->mode = "autohide"; $edit->creten->group = "Impuesto Sobre la Renta"; $edit->reten = new inputField("Retencion de ISLR", 'reten'); $edit->reten->size = 8; $edit->reten->mode = "autohide"; $edit->reten->group = "Impuesto Sobre la Renta"; $gtotal = "Montos Totales"; $edit->subtotal = new inputField("Sub Total", 'subtotal'); $edit->subtotal->size = 8; $edit->subtotal->mode = "autohide"; $edit->subtotal->group = $gtotal; $edit->ivaa = new inputField("IVA Sobre Tasa", 'ivaa'); $edit->ivaa->size = 8; $edit->ivaa->mode = "autohide"; $edit->ivaa->group = $gtotal; $edit->ivag = new inputField("IVA Tasa General", 'ivag'); $edit->ivag->size = 8; $edit->ivag->mode = "autohide"; $edit->ivag->group = $gtotal; $edit->ivar = new inputField("IVA Tasa reducida", 'ivar'); $edit->ivar->size = 8; $edit->ivar->mode = "autohide"; $edit->ivar->group = $gtotal; $edit->exento = new inputField("Exento", 'exento'); $edit->exento->size = 8; $edit->exento->mode = "autohide"; $edit->exento->group = $gtotal; $edit->total = new inputField("Total", 'total'); $edit->total->size = 8; $edit->total->mode = "autohide"; $edit->total->group = $gtotal; $n = $edit->_dataobject->get('numero'); $status = $edit->_dataobject->get("status"); if ($status == 'T') { //$action = "javascript:window.location='" .site_url($this->url.'actualizar/'.$edit->rapyd->uri->get_edited_id()). "'"; //$action = "javascript:window.location='" .site_url($this->url.'actualizar/'.$n)."'"; //$edit->button_status("btn_status",'Ordenar Pago',$action,"TR","show"); $edit->buttons("modify", "save"); } elseif ($status == 'O') { $action = "javascript:window.location='" . site_url($this->url . 'reversar/' . $edit->rapyd->uri->get_edited_id()) . "'"; //$action = "javascript:window.location='" .site_url($this->url.'reversar/'.$n). "'"; $edit->button_status("btn_rever", 'Deshacer Ordenar Pago', $action, "TR", "show"); } else { $edit->buttons("save"); } $edit->buttons("undo", "back"); $edit->build(); $data['content'] = $edit->output; $data['title'] = " {$this->t**s} "; //$data['content'] = $edit->output; //$data['title'] = " $this->t**s "; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function smarty_function_select($params, &$smarty) { // set a few variables $attribute = $params['attribute']; $fallback = TRUE; $use_autocomplete = FALSE; $rowid = ''; $selected = ''; $opt_counter = 0; $data = array('select' => array('attrs' => array()), 'display_tags' => !(isset($params['tags']) && $params['tags'] == 'none')); // append any data attributes passed in through params with the attrs array $data['select']['attrs'] += build_data_attributes($params); $controller_data =& $smarty->getTemplateVars('controller_data'); if (empty($params['force']) && (isset($controller_data[$attribute]) || !empty($params['hidden']))) { if (isset($controller_data['dialog'])) { // force select to be hidden on a dialog $params['hidden'] = ''; } return smarty_function_input($params, $smarty); } $with =& $smarty->getTemplateVars('with'); // not empty = TRUE, empty = FALSE $use_collection = !empty($params['use_collection']); if (!empty($params['model'])) { $model =& $params['model']; } else { $model = $with['model']; } $field = $model->getField($attribute); $cc = new ConstraintChain(); if (!empty($params['constraint'])) { $constraint = $params['constraint']; if (class_exists($constraint . 'Constraint')) { $cname = $constraint . 'Constraint'; $constraint = new $cname($attribute); if (!$constraint instanceof Constraint) { throw new Exception($cname . ' is not a valid Constraint'); } } else { $exp = explode(',', $constraint); $constraint = new Constraint($exp[0], $exp[1], $exp[2]); } $cc->add($constraint); } if (empty($params['alias'])) { $params['alias'] = isset($with['alias']) ? $with['alias'] : ''; } if (!empty($params['alias'])) { $alias = $model->getAlias($params['alias']); $aliasModelName = $alias['modelName']; $newmodel = new $aliasModelName(); $name = $model->get_name() . '[' . $params['alias'] . '][' . $attribute . ']'; $id = $model->get_name() . '_' . $params['alias'] . '_' . $attribute; if (isset($_POST[$model->get_name()][$params['alias']][$attribute])) { $value = $_POST[$model->get_name()][$params['alias']][$attribute]; } elseif ($model->isLoaded()) { $newmodel = $model->{$params}['alias']; $value = $newmodel->{$attribute}; } $model = $newmodel; } if (empty($params['composite'])) { $params['composite'] = isset($with['composite']) ? $with['composite'] : ''; // DEFAULT } if (!empty($params['composite'])) { $alias = $model->getComposite($params['composite']); $aliasModelName = $alias['modelName']; $newmodel = new $aliasModelName(); $name = $model->get_name() . '[' . $aliasModelName . '][' . $attribute . ']'; $id = $model->get_name() . '_' . $aliasModelName . '_' . $attribute; if (isset($_POST[$model->get_name()][$aliasModelName][$attribute])) { $value = $_POST[$model->get_name()][$aliasModelName][$attribute]; } elseif ($model->isLoaded()) { $newmodel = $model->{$params}['composite']; $value = $newmodel->{$attribute}; } $model = $newmodel; } if (isset($params['options'])) { $get_options = $params['options']; } else { $get_options = ''; } if (!isset($params['autocomplete']) || empty($get_options)) { $use_autocomplete = false; } else { $use_autocomplete = true; } if (!is_null($field->options)) { $get_options = $field->options->_data; $use_autocomplete = $field->options->_autocomplete; $text_value = $model->{$model->belongsToField[$attribute]}; if (trim($text_value) == '' && count($get_options) > 0) { $text_value = current($get_options); } $selected = key($get_options); } if (!empty($params['label'])) { $data['select']['label'] = $params['label']; } else { $data['select']['label'] = $field->tag; } if (isset($params['number'])) { $name = $model->get_name() . '[' . $params['number'] . '][' . $attribute . ']'; } elseif (!isset($name)) { $name = $model->get_name() . '[' . $attribute . ']'; } if (isset($params['rowid']) && !empty($params['rowid'])) { $rowid = $params['rowid']; $data['select']['attrs']['data-row-number'] = $params['rowid']; } $id = $model->get_name() . '_' . $attribute . $rowid; if (!isset($name)) { $name = $model->get_name() . '[' . $attribute . ']'; $id = $model->get_name() . '_' . $attribute . $rowid; } if (isset($params['postfix'])) { $name .= $params['postfix']; } // set field (data) attribute if (isset($field) && !empty($field)) { $data['select']['attrs']['data-field'] = $field->name; } else { $data['select']['attrs']['data-field'] = $attribute; } if (!empty($params['depends'])) { $depends = explode(',', $params['depends']); } elseif (!is_null($field->options->_depends)) { $depends = array_keys($field->options->_depends); } else { $depends = ''; } // echo 'Smarty function.select depends='.$depends.'<br>'; if (!empty($params['constrains'])) { $affects = explode(',', $params['constrains']); $constrains = true; } elseif (!is_null($field->options->_affects)) { $affects = array_keys($field->options->_affects); $constrains = true; } else { $affects = ''; $constrains = false; } // set the selected value from the value of the field, if present if ($model->isLoaded()) { $selected = $model->{$attribute}; } elseif (isset($controller_data[$attribute])) { $selected = $controller_data[$attribute]; } // set the selected value from the params value // can override the value of the field, if present if (isset($params['value'])) { $selected = $params['value']; } $autocomplete_select_limit = get_config('AUTOCOMPLETE_SELECT_LIMIT'); if (!empty($get_options) && !isset($params['forceselect']) && count($get_options) > $autocomplete_select_limit) { $use_autocomplete = true; } if (isset($model->belongsToField[$attribute])) { $x = $model->belongsTo[$model->belongsToField[$attribute]]["model"]; $controllername = strtolower($x) . 's'; if (isset($_SESSION['cache']['select'][$controllername])) { $data['select']['fk_link']['module'] = $_SESSION['cache']['select'][$controllername]; } else { $component = new ModuleComponent(); $component->loadBy(array('name', 'type'), array($controllername . 'controller', 'C')); if ($component->isLoaded()) { $data['select']['fk_link']['module'] = $_SESSION['cache']['select'][$controllername] = $component->module_name; } } if (isset($data['select']['fk_link']['module'])) { $data['select']['fk_link']['controller'] = $controllername; $data['select']['fk_link']['action'] = 'new'; } if (isset($params['data'])) { if ($params['data'] instanceof DataObjectCollection) { $options = $params['data']->getAssoc(); } elseif (is_array($params['data'])) { $options = $params['data']; } else { throw new Exception('"data" paramater should be an associative array, or a DataObjectCollection'); } } elseif (empty($get_options)) { if ($model->belongsTo[$model->belongsToField[$attribute]]["cc"] instanceof ConstraintChain) { $cc->add($model->belongsTo[$model->belongsToField[$attribute]]["cc"]); } if (!empty($depends)) { foreach ($depends as $depends_field) { if (!is_null($model->{$depends_field})) { $cc->add(new Constraint($depends_field, '=', $model->{$depends_field})); } } } $model->belongsTo[$model->belongsToField[$attribute]]["cc"] = $cc; if (!isset($params['forceselect']) && $model->getOptionsCount($attribute) > $autocomplete_select_limit) { $use_autocomplete = TRUE; $text_value = $model->{$model->belongsToField[$attribute]}; if (trim($text_value) == '') { if (empty($selected) && !$model->isLoaded() && $field->has_default) { $selected = $field->default_value; } $temp = new $x(); $temp->load($selected); $text_value = $temp->getIdentifierValue(); } } else { $x = DataObjectFactory::Factory($x); if ($model->checkUniqueness($attribute)) { // TODO: this can be inefficient in large data sets // needs to be 'not exists' correlated subquery $cc->add(new Constraint($x->idField, 'NOT IN', '(SELECT ' . $attribute . ' FROM ' . $model->getTableName() . ')')); $options = $x->getAll($cc, TRUE, $use_collection); $fallback = FALSE; } elseif ($attribute == 'assigned') { $c_user = $smarty->getTemplateVars('current_user'); $cc = new ConstraintChain(); $db = DB::Instance(); if (!is_null($c_user->person_id)) { $cc->add(new Constraint('person_id', 'IN', '(SELECT px.id FROM person px JOIN company cx ON (px.company_id=cx.id) JOIN person pz ON (pz.company_id=cx.id) WHERE pz.id=' . $db->qstr($c_user->person_id) . ')')); } $options = $x->getAll($cc, TRUE, $use_collection); } elseif (get_class($x) == 'User') { $options = $x->getActive($cc, FALSE); } else { $options = $x->getAll($cc, FALSE, $use_collection); } } } } elseif ($model->hasParentRelationship($attribute) && !isset($params['ignore_parent_rel'])) { $db = DB::Instance(); $x = clone $model; if ($model->isLoaded()) { $cc->add(new Constraint($model->idField, '<>', $model->{$model->idField})); } $options = $x->getAll($cc, FALSE, $use_collection); } elseif ($model->isEnum($attribute)) { //enumeration $options = $model->getEnumOptions($attribute); foreach ($options as $key => $option) { if ($selected == $option) { $selected = $key; break; } } } if ($field->not_null == 1) { $data['select']['label'] .= ' *'; $data['select']['class'][] = 'required'; } if (isset($_POST[$model->get_name()][$attribute])) { $selected = $_POST[$model->get_name()][$attribute]; } elseif (isset($_SESSION['_controller_data'][get_class($model)][$attribute])) { $selected = $_SESSION['_controller_data'][get_class($model)][$attribute]; } elseif (isset($_POST[$model->get_name()][$params['number']])) { $selected = $_POST[$model->get_name()][$params['number']][$attribute]; } if (empty($selected) && $field->has_default && !$model->isLoaded()) { $selected = $field->default_value; } if (isset($params['nonone']) && $params['nonone'] == 'true' || !is_null($field->options->_nonone) && $field->options->_nonone) { $data['select']['class'][] = "nonone"; } if (!empty($depends)) { $data['select']['attrs']['data-depends'] = htmlspecialchars(json_encode($depends)); } if (!empty($affects)) { $data['select']['attrs']['data-constrains'] = htmlspecialchars(json_encode($affects)); } //*************************** // COMPILE SELECT ATTRIBUTES $data['select']['attrs']['name'] = $name; $data['select']['attrs']['id'] = $id; if (isset($data['select']['fk_link'])) { $data['select']['id'] = $id; } // join the select class items with a space and pop them in the attrs class item if (!empty($data['select']['class'])) { $data['select']['attrs']['class'] = implode(' ', $data['select']['class']); } // append any class passed in from params if (!empty($params['class'])) { $data['select']['attrs']['class'] .= ' ' . $params['class']; } // For new records, initialise the model attribute with the selected value if (!empty($selected)) { $model->{$attribute} = $selected; } if (!$use_autocomplete || isset($params['multiple']) && $params['multiple']) { if ($constrains) { $data['select']['attrs']['class'] .= ' uz-constrains'; } if (isset($params['multiple']) && $params['multiple']) { $data['dd']['attrs']['class'] = 'for_multiple'; $data['select']['id'] = $id; $data['select']['attrs']['name'] = $data['select']['attrs']['name'] . '[]'; $data['select']['attrs']['multiple'] = 'multiple'; } if (isset($params['onchange'])) { $data['select']['attrs']['onchange'] = $params['onchange']; } if (isset($params['size'])) { $data['select']['attrs']['size'] = $params['size']; } if (isset($params['disabled'])) { $data['select']['attrs']['disabled'] = 'disabled'; } // for the sake of it, trim the class string $data['select']['attrs']['class'] = trim($data['select']['attrs']['class']); // build the attribute string // $data['select']['attrs'] is no longer an array!!! $data['select']['attrs'] = build_attribute_string($data['select']['attrs']); //***************** // COMPILE OPTIONS // check whether required field if (!$field->not_null == 1 && (!isset($params['nonone']) || $params['nonone'] != 'true') && (is_null($field->options->_nonone) || !$field->options->_nonone)) { $opt_counter++; $option_attrs = array('value' => ''); if (empty($selected)) { $option_attrs['selected'] = 'selected'; $selected = 'None'; } $data['select']['options'][$opt_counter]['attrs'] = build_attribute_string($option_attrs); $data['select']['options'][$opt_counter]['value'] = 'None'; } if (isset($params['start'])) { $opt_counter++; $option_attrs = array('value' => ''); if (empty($selected)) { $option_attrs['selected'] = 'selected'; $selected = $params['start']; } $data['select']['options'][$opt_counter]['attrs'] = build_attribute_string($option_attrs); $data['select']['options'][$opt_counter]['value'] = $params['start']; } // fallback is a horrible hack for now (for uniqueness constraints on dropdowns) if ($fallback && is_array($get_options)) { $options = $get_options; } if (!empty($options)) { foreach ($options as $key => $value) { $option_attrs = array(); $opt_counter++; $option_attrs['value'] = h($key, ENT_COMPAT); if (is_array($selected) && in_array($key, $selected) || $selected == $key) { $option_attrs['selected'] = 'selected'; } $data['select']['options'][$opt_counter]['attrs'] = build_attribute_string($option_attrs); $data['select']['options'][$opt_counter]['value'] = h($value); $data['autocomplete'] = false; } } $data['dt']['attrs'] = empty($data['dt']['attrs']) ? '' : build_attribute_string($data['dt']['attrs']); $data['dd']['attrs'] = empty($data['dd']['attrs']) ? '' : build_attribute_string($data['dd']['attrs']); } elseif (is_null($field->options) && !empty($get_options)) { if (empty($selected)) { $selected = key($get_options); } $data['autocomplete'] = true; $data['data_inline'] = true; $data['select']['selected'] = $selected; $data['select']['value'] = $get_options[$selected]; $data['select']['options'] = json_encode(dataObject::toJSONArray($get_options)); $data['select']['attrs']['class'] = 'uz-autocomplete ui-autocomplete-input icon ' . $data['select']['attrs']['class']; } else { $data['autocomplete'] = true; $data['data_inline'] = false; if (isset($params['action'])) { $data['select']['attrs']['data-action'] = $params['action']; } elseif (!is_null($field->options)) { $data['select']['attrs']['data-action'] = $field->options->_action; } else { $data['select']['attrs']['data-action'] = 'getOptions'; } if (!empty($params['identifierfield'])) { $data['select']['attrs']['data-identifierfield'] = json_encode(explode(',', $params['identifierfield'])); } elseif (!is_null($field->options->_identifierfield)) { $data['select']['attrs']['data-identifierfield'] = json_encode(array_keys($field->options->_identifierfield)); } else { $data['select']['attrs']['data-identifierfield'] = '""'; } if (!empty($params['use_collection'])) { $data['select']['attrs']['data-use_collection'] = $params['use_collection'] ? 'true' : 'false'; } elseif (!is_null($field->options->_use_collection)) { $data['select']['attrs']['data-use_collection'] = $field->options->_use_collection ? 'true' : 'false'; } else { $data['select']['attrs']['data-use_collection'] = '""'; } if (empty($text_value) && !empty($selected)) { $text_value = $selected; } $text_attribute = $attribute . '_text'; $text_name = str_replace($attribute, $text_attribute, $name); if (isset($_POST[$model->get_name()][$text_attribute])) { $text_value = $_POST[$model->get_name()][$text_attribute]; } elseif (isset($_SESSION['_controller_data'][get_class($model)][$text_attribute])) { $text_value = $_SESSION['_controller_data'][get_class($model)][$text_attribute]; } elseif (isset($_POST[$model->get_name()][$params['number']])) { $text_value = $_POST[$model->get_name()][$params['number']][$text_attribute]; } $data['select']['attrs']['data-attribute'] = $attribute; $data['select']['attrs']['class'] = 'uz-autocomplete ui-autocomplete-input icon ' . $data['select']['attrs']['class']; $attrs = array('name' => $data['select']['attrs']['name'], 'id' => $data['select']['attrs']['id'], 'value' => h($selected, ENT_COMPAT), 'data-text_id' => $data['select']['attrs']['id'] . '_text'); if (isset($data['select']['attrs']['data-depends'])) { $attrs['data-depends'] = $data['select']['attrs']['data-depends']; } if (isset($data['select']['attrs']['data-constrains'])) { $attrs['data-constrains'] = $data['select']['attrs']['data-constrains']; unset($data['select']['attrs']['data-constrains']); } if ($constrains) { $attrs['class'] = '"uz-constrains"'; } $data['select']['attrs']['data-id'] = $data['select']['attrs']['id']; $data['select']['attrs']['value'] = $text_value; $data['select']['attrs']['id'] = $data['select']['attrs']['id'] . '_text'; $data['select']['attrs']['name'] = $text_name; $data['select']['attrs_text'] = build_attribute_string($data['select']['attrs']); $data['select']['attrs'] = build_attribute_string($attrs); } // this should be further up? if (prettify($params['attribute']) == 'EGS_HIDDEN_FIELD') { return ''; } // fetch smarty plugin template return smarty_plugin_template($smarty, $data, 'function.select'); }
public function publishArticle($articleID) { //merge translated page content and create pdf $sql = 'select * from pages where articleID= :articleID and language= :language'; $conn = dataObject::connect(); try { $st = $conn->prepare($sql); $st->bindValue(":articleID", $articleID, PDO::PARAM_INT); $st->bindValue(":language", 'hindi', PDO::PARAM_STR); $st->execute(); $rows = $st->fetchAll(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to retrieve pages:" . $e->getMessage()); } $str = ''; foreach ($rows as $row) { $pageObj = new Page($row['file_path']); $str .= $pageObj->loadContentTranslated(); } //add to file $handle = fopen("../translations/{$articleID}_translated.txt", 'w'); fwrite($handle, $str); fclose($handle); //Make entry into database $sql = "insert into translations(articleID,language,file_size,file_name,file_path) values( :articleID, :language, :filesize, :filename, :filepath);"; try { $st = $conn->prepare($sql); $st->bindValue(":articleID", $articleID, PDO::PARAM_INT); $st->bindValue(":language", 'hindi', PDO::PARAM_STR); $st->bindValue(":filesize", filesize("../translations/{$articleID}_translated.txt"), PDO::PARAM_INT); $st->bindValue(":filename", "{$articleID}_translated.txt", PDO::PARAM_STR); $st->bindValue(":filepath", realpath("../translations/{$articleID}_translated.txt"), PDO::PARAM_STR); $st->execute(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to add translation:" . $e->getMessage()); } $sql = "update articles set no_of_translations = no_of_translations+1 where articleID= :articleID"; try { $st = $conn->prepare($sql); $st->bindValue(":articleID", $articleID, PDO::PARAM_INT); $st->execute(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to update no-of-translations:" . $e->getMessage()); } }
$st->execute(); $row = $st->fetch(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to retrieve:" . $e->getMessage()); } $EPageObj = new Page($row['file_path']); try { $st = $conn->prepare($sql); $st->bindValue(":articleID", $articleObj->returnID(), PDO::PARAM_INT); $st->bindValue(":pageno", $pageno, PDO::PARAM_INT); $st->bindValue(":language", 'hindi', PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); } catch (PDOException $e) { dataObject::disconnect($conn); die("failed to retrieve:" . $e->getMessage()); } $HPageObj = new Page($row['file_path']); $formaction = "verifypage1.php?title=" . urlencode($title) . "&pageno=" . urlencode($pageno) . "&count=" . urlencode($count); ?> <div class='container-fluid'> <form action='<?php echo $formaction; ?> ' method='post'> <div class='row'> <div class='col-xs-6'> <textarea name='englishContent' id='englishContent' rows='20' cols='40' readonly> <?php echo $EPageObj->loadContent();