/** * Replaces an element * * @return Element|bool * @since 1.3.3 */ public static function set_element($key, $element) { if (!$element instanceof Elements\Element) { $element = create_element($element); } self::$elements[$key] = $element; return $element; }
/** * Create many elements objects at once. * * @return Nmwdhj\Elements\Element[] * @throws Nmwdhj\Exception * @since 1.2 */ function create_elements(array $elements) { $objects = array(); foreach ($elements as $key => $value) { $objects[$key] = create_element($value); } return $objects; }
/** * Convert a numeric column index into an alpha column heading. * * @params $return : string - Indicates how the xml should be output. D forces an xls download. S returns the xml as a string. * @author Daniel Razafsky * @return void/string - No value is returned unless $return is 'S' in which case the xml string representing the worksheet is returned. */ function output($return = 'D', $nmfile) { // Create the workbook object that acts as the root element $workbook = create_element($this->_dom, 'Workbook'); append_child($this->_dom, $workbook); append_child($workbook, create_attribute($this->_dom, 'xmlns', 'urn:schemas-microsoft-com:office:spreadsheet')); append_child($workbook, create_attribute($this->_dom, 'xmlns:o', 'urn:schemas-microsoft-com:office:office')); append_child($workbook, create_attribute($this->_dom, 'xmlns:x', 'urn:schemas-microsoft-com:office:excel')); append_child($workbook, create_attribute($this->_dom, 'xmlns:ss', 'urn:schemas-microsoft-com:office:spreadsheet')); append_child($workbook, create_attribute($this->_dom, 'xmlns:html', 'http://www.w3.org/TR/REC-html40')); // Add in the styles section (assuming we have styles) if (!empty($this->_styles)) { $styles = create_element($this->_dom, 'Styles'); foreach ($this->_styles as $style_id => $cur_style) { append_child($styles, $cur_style); } append_child($workbook, $styles); } // Loop over all the worksheets adding them to the workbook foreach ($this->_worksheets as $cur_worksheet) { $worksheet = create_element($this->_dom, 'Worksheet'); append_child($worksheet, create_attribute($this->_dom, 'ss:Name', $cur_worksheet->name)); $table = create_element($this->_dom, 'Table'); // Loop over all of the current worksheet's rows and append them foreach ($cur_worksheet->cells['row'] as $row_index => $cur_row) { $row = create_element($this->_dom, 'Row'); append_child($row, create_attribute($this->_dom, 'ss:Index', $row_index)); // Loop over all the columns in the row and append them foreach ($cur_row['col'] as $col_index => $cur_cell) { $cell = create_element($this->_dom, 'Cell'); append_child($cell, create_attribute($this->_dom, 'ss:Index', $col_index)); if (!empty($cur_cell['style'])) { append_child($cell, create_attribute($this->_dom, 'ss:StyleID', $cur_cell['style'])); } if (!empty($cur_cell['formula'])) { if ('=' != substr($cur_cell['formula'], 0, 1)) { $cur_cell['formula'] = '=' . $cur_cell['formula']; } append_child($cell, create_attribute($this->_dom, 'ss:Formula', $cur_cell['formula'])); } $data = create_element($this->_dom, 'Data'); append_child($data, create_text_node($this->_dom, $cur_cell['data'])); append_child($data, create_attribute($this->_dom, 'ss:Type', !empty($cur_cell['type']) ? $cur_cell['type'] : 'String')); // We do still want to set an empty data element for the cell though append_child($cell, $data); append_child($row, $cell); } append_child($table, $row); } // Add the table to the workshet append_child($worksheet, $table); // Let's not forget to add the worksheet to the workbook append_child($workbook, $worksheet); } switch ($return) { case 'S': return save_xml($this->_dom); break; case 'D': default: $export_file = 'data_' . str_replace("-", "_", $nmfile) . '.xls'; ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Pragma: no-cache'); header('Expires: 0'); header('Content-Transfer-Encoding: none'); header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera header('Content-type: application/x-msexcel'); // This should work for the rest header('Content-Disposition: attachment; filename="' . basename($export_file) . '"'); $CI =& get_instance(); $CI->output->append_output(save_xml($this->_dom)); break; } }
echo "Image not valid. Please try again."; } } else { echo "Not all required fields are filled.."; } } $galleries = getGalleries($_SESSION['user_id']); //ako nema ni jednu galeriju dosad - nek ju napravi if (empty($galleries)) { header('Location: new_gallery.php'); exit; } //napravi izbor korisnikovih galerija $options = array(); foreach ($galleries as $key => $value) { array_push($options, create_element("option", true, ["contents" => $value, "value" => $key])); } $input = create_select(["name" => "galleryOption", "contents" => $options]); function validatePicture($picture) { $MIN_WIDTH = 128; $MIN_HEIGHT = 128; $MAX_SIZE = 512000; //500 kB $dimensions = getimagesize($picture); if ($dimensions === false || $dimensions[0] == 0 || $_FILES['file']['size'] > $MAX_SIZE) { echo "Velicina prevelika: " . $_FILES['file']['size'] . "\n"; return false; } if ($dimensions[0] < $MIN_WIDTH || $dimensions[1] < $MIN_HEIGHT) { echo "Velicina premala\n";
session_start(); if (!isset($_SESSION['user_id'])) { header('Location: index.php'); } $images = getImagesByUser('slike.txt'); $imgGallery = getGalleriesIds(array_keys($images), 'slike.txt'); $galleries = getGalleriesNames(array_values($imgGallery), 'galerije.txt'); $brElement = create_element("br", false, null); create_doctype(); begin_html(); begin_head(); echo create_element("a", true, ["href" => "index.php", "contents" => "Home page"]), $brElement; echo create_element("a", true, ["href" => "upload.php", "contents" => "Upload a new photo"]), $brElement; echo create_element("a", true, ["href" => "new_gallery.php", "contents" => "Create a new gallery"]), $brElement; echo create_element("h1", true, ["contents" => "Your photos:"]); end_head(); begin_body(); $listElements = array(); foreach ($images as $key => $value) { $imgContent = create_element("img", false, ["src" => "picture.php?id={$key}&size=small"]); $imgTitle = create_element("h3", true, ['contents' => $value]); $galleryTitle = create_element("h5", true, ['contents' => $galleries[$imgGallery[$key]]]); $editLink = create_element("a", true, ['href' => "editphoto.php?id={$key}", 'contents' => 'Edit photo']); $elementContent = $imgTitle . $brElement . $imgContent . $brElement . $galleryTitle . $brElement; $elementContent .= $editLink . $brElement; $listElement = create_element("li", true, ["contents" => $elementContent]); array_push($listElements, $listElement); } echo create_element("ul", true, ["contents" => $listElements]); end_body(); end_html();
$questionId = 0; $_SESSION['cat1counter'] = $categoryOneCounter; $_SESSION['cat2counter'] = $categoryTwoCounter; $_SESSION['cat3counter'] = $categoryThreeCounter; foreach ($categoryOne as $key => $value) { $cell1 = $key; $options = array(); for ($i = 0; $i < count($value) - 1; $i++) { array_push($options, create_element("option", true, ["contents" => $value[$i]])); } $_SESSION["1_.{$questionId}._answer"] = $value[count($value) - 1]; $cell2 = create_select(["name" => '1_' . $questionId, "contents" => $options]); echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $cell2]))]); $questionId++; } $brTag = create_element("br", false, null); $questionId = 0; foreach ($categoryTwo as $key => $value) { $cell1 = $key; $options = array(); for ($i = 0; $i < count($value) - 1; $i++) { array_push($options, create_input(["type" => "checkbox", "value" => $value[$i], "name" => '2_' . $questionId . '_checklist[]']) . $value[$i]); } $_SESSION["2_.{$questionId}._answer"] = $value[count($value) - 1]; $content = implode($brTag, $options); echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $content]))]); $questionId++; } $questionId = 0; foreach ($categoryThree as $key => $value) { $cell1 = $key;
$galleries = getGalleries($_SESSION['user_id']); $galleryId = array_values(getGalleriesIds(array($_GET['id']), 'slike.txt'))[0]; //napravi izbor korisnikovih galerija $options = array(); foreach ($galleries as $key => $value) { if ($key == $galleryId) { array_push($options, create_element("option", true, ["contents" => $value, "value" => $key, "selected" => "selected"])); } else { array_push($options, create_element("option", true, ["contents" => $value, "value" => $key])); } } $input = create_select(["name" => "galleryOption", "contents" => $options]); $pictureId = $_GET['id']; $pictureTitle = getImageName($pictureId); $pictureDescription = getImageDescription($pictureId); echo create_element("img", false, ["src" => "picture.php?id={$pictureId}&size=original"]); ?> <form id='pic_upload' action='' method='post' accept-charset='UTF-8'> <fieldset> <legend>Edit your picture</legend> <input type='hidden' name='submitted' id='submitted' value='1'/> <label for='title'>Title*: </label> <input type='text' name='title' id='title' value=<?php echo $pictureTitle; ?> maxlength="100" required/><br> <br> <label for='description'>Description:</label> <textarea name="description" form="pic_upload"><?php echo $pictureDescription;