public function gen() { $ir = "define i32 @{$this->obj->name}("; /* collect the arguments */ if (!empty($this->obj->arguments)) { foreach ($this->obj->arguments as $arg) { $var = \Tables::getLocalVariable($this->obj->function, $this->obj->name); $type = ""; /* get the correct type */ for ($i = 0; $i <= $this->obj->line; $i++) { if (isset($var->type[$i])) { $type = $var->type[$i]; } } $ir .= \Misc::getType($type) . " %{$arg->name}, "; } $ir = substr($ir, 0, -2); } $ir .= ") {" . PHP_EOL; /* compile the code inside the function */ foreach ($this->obj->content as $item) { $gen = new \Codegen\Gen(array($item)); $ir .= $gen->gen(); } $ir .= "}" . PHP_EOL . PHP_EOL; \Tables::addFunc($this->obj->name, "i32"); return $ir; }
public static function View() { Tables::tableCheck(); global $wpdb; $table = $wpdb->prefix . 'ar_profiles'; return $wpdb->get_results("SELECT * FROM {$table}"); }
function createPage($smarty) { $smarty->assign('exams', Tables::exams(true)); $smarty->assign('planning', Tables::planning(true, 'exams')); $smarty->assign('schedule', Queries::article('exams')); return $smarty; }
function createPage($smarty) { $subjects = Queries::subjects(); foreach ($subjects as $index => $subject) { $assignments = Queries::assignments(true, $subject->abbreviation); $exams = Queries::exams(true, $subject->abbreviation); $subjects[$index]->ass_line_index = -1; $subjects[$index]->ex_line_index = -1; $subjects[$index]->assignments = $assignments; $subjects[$index]->exams = $exams; foreach ($assignments as $index2 => $assigment) { if (strtotime($assigment->end_date . ' ' . $assigment->end_time) < strtotime('now')) { $subjects[$index]->ass_line_index = $index2; } } foreach ($exams as $index2 => $exam) { if (strtotime($exam->date) < strtotime('today')) { $subjects[$index]->ex_line_index = $index2; } } } $smarty->assign('subjects', $subjects); $smarty->assign('events', Tables::events(true)); return $smarty; }
/** * list tables * * Recognize following variants: * - 'no_anchor' to list items attached to one particular anchor * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // initialize variables $prefix = $suffix = $icon = ''; // the url to view this item $url = Tables::get_url($item['id']); // flag tables created or updated very recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } $label = Skin::strip($item['title'], 10); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'table', $icon); } // end of processing SQL::free($result); return $items; }
public function gen() { $reg = \Tables::alloc(); $ir = "\t%{$reg} = alloca i32" . PHP_EOL; $ir .= "\tstore {$this->arg()}, i32* %{$reg}" . PHP_EOL; return $ir; }
public function gen() { $ir = ""; $leftname = "\\Codegen\\Generator\\" . \Misc::baseClass($this->obj->left); $left = new $leftname($this->obj->left); $ir .= $left->gen(); $rightname = "\\Codegen\\Generator\\" . \Misc::baseClass($this->obj->right); $right = new $rightname($this->obj->right); $ir .= $right->gen(); $leftreg = \Tables::$register_alloc - 1; $rightreg = $leftreg + 1; if ($this->obj->left instanceof \Parser\Parsers\Integer) { $reg1 = \Tables::alloc(); /* holds the left value */ $ir .= "\t%{$reg1} = load i32* %{$leftreg}" . PHP_EOL; } else { $reg1 = $leftreg; } if ($this->obj->right instanceof \Parser\Parsers\Integer) { $reg2 = \Tables::alloc(); /* holds the right value */ $ir .= "\t%{$reg2} = load i32* %{$rightreg}" . PHP_EOL; } else { $reg2 = $rightreg; } $reg3 = \Tables::alloc(); /* holds the result */ $ir .= "\t%{$reg3} = sub nsw i32 %{$reg1}, %{$reg2}" . PHP_EOL; $this->resultreg = $reg3; return $ir; }
public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public function listing() { global $db; $collections = $db->select("collections", null, '*', null, "name"); $table = new Tables(); $table->start(); $table->head("name,products #,sm,sm,sm,sm,sm,sm,sm"); if ($collections) { foreach ($collections as $collection) { $badge = $this->test_data($collection); $id = $collection['id']; $count_active = $db->select("products", "`collection_id`='{$id}' AND `deleted` != '1'"); if ($count_active) { $count_active = count($count_active); } $count_deleted = $db->select("products", "`collection_id`='{$id}' AND `deleted` = '1'"); if ($count_deleted) { $count_deleted = " (" . count($count_deleted) . ")"; } $table_entry = $collection['name'] . "||"; $table_entry .= "{$count_active}{$count_deleted}||"; $count_missingBC = $db->select("products", "`collection_id`='{$id}' AND `barcode` IS NULL AND `bc_overide` = '0'"); if ($collection['barcodes'] and $_SESSION['settings']['barcodes'] and $collection['variation_ids'] == null and $count_missingBC) { $table_entry .= $this->button("barcodes.php?c={$id}", "Add Barcodes", "warning") . "||"; } else { $table_entry .= "||"; } if (!$collection['postage'] and $_SESSION['settings']['shipping_api']) { $table_entry .= $this->button("collections.php?c={$id}", "Postage Type Required", "danger") . "||"; } else { $table_entry .= "||"; } $table_entry .= $this->button("images.php?c={$id}", "images", "warning") . "||"; $table_entry .= $this->button("collections.php?c={$id}", "edit", "primary", $badge) . "||"; if ($collection['variation_ids'] == null) { $table_entry .= $this->button("variations.php?c={$id}", "add variations") . "||"; } else { $table_entry .= $this->button("variations.php?c={$id}", "edit variations") . "||"; } $table_entry .= $this->button("products.php?c={$id}&f=analyse", "analyse", "info") . "||"; $table_entry .= $this->button("products.php?c={$id}", "select"); $table->entry($table_entry); } } $table->end(); }
public function __construct($token) { $this->code = $token->content; $this->line = $token->line; $this->string = trim(substr($this->code, 1, -1)); $this->string = str_replace("\\n", "\\0A", $this->string); $this->id = \Tables::addString($this->string); }
public function process($array = array(), $params = array()) { global $db; $params = array_merge(array('page' => $this->page, 'display_items' => 20, 'render' => false), $params); $table = new Tables(); $start = ($params['page'] - 1) * $params['display_items']; $end = $params['page'] * $params['display_items'] - 1; if (isset($array['headers'])) { $params['render'] = true; $table->start('search-table'); $table->head($array['headers']); $headers = $array['headers']; unset($array['headers']); } $data_slice = array_slice($array, $start, $end); foreach ($data_slice as $data) { unset($table_entry); foreach ($headers as $header) { if ($header !== 'sm') { if (!is_array($data[$header])) { $table_entry[] = $data[$header]; } else { $table_entry[] = "<ul class='list-group'><li class='list-group-item'>" . implode("</li><li class='list-group-item'>", $data[$header]) . "</li></ul>"; } } else { if ($data['type'] == 'collections') { $table_entry[] = $this->button('collections.php?c=' . $data['id'], 'view'); } else { $collection_id = $db->select('products', $data['id'], 'collection_id', 1); $collection_id = $collection_id['collection_id']; $table_entry[] = $this->button("products.php?c={$collection_id}&p=" . $data['id'], 'view'); } } } $table->entry($table_entry); } if ($params['render']) { $table->end(); } return ceil(count($array) / $params['display_items']); }
public function gen() { $ir = ""; $function = $this->obj->content[0]->string; /* convert the C types to LLVM IR */ $function = preg_replace("/char\\s*\\*\\s*.+?(,|\\))/", "i8*\$1", $function); $function = preg_replace("/int([,( ])/", "i32\$1", $function); /* add a @-symbol in front of the function name */ $function = preg_replace("/(.+? )(.+?\\()/", "\$1@\$2", $function); \Tables::addDeclaration($function); return $ir; }
function createPage($smarty) { $item = Queries::examWithId(Input::get('id', 'get')); if (empty($item->id)) { Redirect::error(404); } $smarty->assign('item', $item); $smarty->assign('table_parentT', 'exams'); $smarty->assign('table_parentI', $item->id); $smarty->assign('planning', Tables::planning(true, 'exams', $item->id)); return $smarty; }
public function arg() { $ir = ""; $var = \Tables::getLocalVariable($this->obj->function, $this->obj->name); /* get the correct type */ for ($i = 0; $i <= $this->obj->line; $i++) { if (isset($var->type[$i])) { $type = $var->type[$i]; } } $ir .= \Misc::getType($type) . " %{$var->name}"; return $ir; }
function createPage($smarty) { $subject = DB::instance()->get("subjects", array("", "abbreviation", "=", Input::get('subject', 'get')))->first(); if (empty($subject->id)) { Redirect::error(404); } $smarty->assign('subject', $subject); $smarty->assign('links', json_decode($subject->links)); $smarty->assign('events', Tables::events(true, $subject->abbreviation)); $smarty->assign('table_parentT', 'subjects'); $smarty->assign('table_parentI', $subject->id); $smarty->assign('planning', Tables::planning(true, 'subjects', $subject->id)); return $smarty; }
public function listing() { global $db; $table = new Tables(); $collections = $db->select("collections", null, '*', null, "name"); $table->start(); $table->head("collections,sm,sm"); if ($collections) { foreach ($collections as $key => $collection) { $id = $collection['id']; $name = $collection['name']; $disallow = $db->select("products", "(`filename` IS NULL OR `filename` = '') AND `collection_id` = '{$id}'"); $exporting = $db->select("products", "`exported` = '0' AND `collection_id` = '{$id}'"); $unapproved = $db->select("products", "`exported` = '0' AND `approved` = '0' AND `collection_id` = '{$id}'"); if ($disallow and $this->settings['filenames']) { $ct = count($disallow); // $button = "<a class='btn btn-danger btn-xs text-capitalize' href='export.php?c=$id&filename=prefix'>export using filename prefix</a>"; $button = "<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}&filename=fix'>export using sku fix</a>"; $button .= "||<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}&filename=sku'>export using sku override</a>"; } else { if ($exporting) { $count['unapproved'] = $unapproved ? count($unapproved) : 0; $count['exporting'] = $exporting ? count($exporting) : 0; if ($count['unapproved'] == $count['exporting']) { $button = "||<a class='btn btn-warning btn-xs text-capitalize' href='export.php?c={$id}'>awaiting approval <span class='badge'>" . $count['unapproved'] . "</span></a>"; } else { $button = "||<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}'>export <span class='badge'>" . $count['exporting'] . "</span></a>"; } } else { $button = "||<a class='btn btn-default btn-xs text-capitalize disabled' href=''>export <span class='badge'>0</span></a>"; } } $table->entry("{$name}||{$button}"); } } $table->end(); }
public function gen() { if (is_object($this->obj->content[0])) { /* it is a arithmetic expression */ $ir = ""; $name = "\\Codegen\\Generator\\" . \Misc::baseClass($this->obj->content[0]); $obj = new $name($this->obj->content[0]); $var =& \Tables::updateLocalVariable($this->obj->function, $this->obj->name); $ir .= $obj->gen(); for ($i = 0; $i <= $this->obj->line; $i++) { if (isset($var->type[$i])) { $type = $var->type[$i]; } } $var->type[$this->obj->line] = $type | \Tables::POINTER; $var->type[$this->obj->line] &= ~\Tables::POINTER; $var->name = \Tables::$register_alloc; } elseif (!is_null(\Tables::localVariable($this->obj->function, $this->obj->name))) { /* allocate and get everything ready */ $reg1 = \Tables::alloc(); /* the reg number */ $reg2 = \Tables::alloc(); /* the reg number */ $var =& \Tables::updateLocalVariable($this->obj->function, $this->obj->name); /* our reference to the variable */ /* get the correct type */ for ($i = 0; $i <= $this->obj->line; $i++) { if (isset($var->type[$i])) { $type = $var->type[$i]; } } $type = \Misc::getType($type); /* its type */ $name = "\\Codegen\\Generator\\" . \Misc::baseClass($this->obj->content[0]); $obj = new $name($this->obj->content[0]); /* the code that is to be moved into the reg */ $code = $obj->arg(); /* change the name of the variable to the new register */ $var->name = $reg2; /* generate the code */ $ir = "\t%{$reg1} = alloca {$type}" . PHP_EOL; /* allocate the register */ $ir .= "\tstore " . $code . ", {$type}* %{$reg1}" . PHP_EOL; /* store our value in it */ $ir .= "\t%{$reg2} = load {$type}* %{$reg1}" . PHP_EOL; /* move it into a register we don't have to reference it as a pointer */ } return $ir; }
public function gen() { $ir = ""; if (\Tables::declaration($this->obj->name) || \Tables::func($this->obj->name)) { $gen = array(); $ir .= "\t; prepare the arguments" . PHP_EOL; for ($i = 0; $i < count($this->obj->content); $i++) { $arg = $this->obj->content[$i]; if (\Misc::baseClass($arg) == "Addition" || \Misc::baseClass($arg) == "Subtraction" || \Misc::baseClass($arg) == "Multiplication" || \Misc::baseClass($arg) == "Division" || \Misc::baseClass($arg) == "Call") { $name = "\\Codegen\\Generator\\" . \Misc::baseClass($arg); $obj = new $name($arg); $ir .= $obj->gen(); $gen[$i] = $obj; } } if (\Tables::declaration($this->obj->name)) { $dec = \Tables::getDeclaration($this->obj->name); } elseif (\Tables::func($this->obj->name)) { $dec = \Tables::getFunc($this->obj->name); } $reg = \Tables::alloc(); $this->result = $reg; $ir .= "\t; call {$dec->name}" . PHP_EOL; if (empty($dec->args)) { $ir .= "\t%{$reg} = call {$dec->return} @{$dec->name}"; } else { $ir .= "\t%{$reg} = call {$dec->return} {$dec->args}* @{$dec->name}"; } if (count($this->obj->content) > 0) { for ($i = 0; $i < count($this->obj->content); $i++) { $arg = $this->obj->content[$i]; if (isset($gen[$i]) && !empty($gen[$i])) { $obj = $gen[$i]; } else { $name = "\\Codegen\\Generator\\" . \Misc::baseClass($arg); $obj = new $name($arg); } $ir .= $obj->arg() . ", "; } $ir = substr($ir, 0, -2); } $ir .= ")" . PHP_EOL; $ir .= "\t; end of call to {$dec->name}" . PHP_EOL . PHP_EOL; } else { error("unknown function in line {$this->obj->line}"); } return $ir; }
/** * Setup additional keys/values when searching all created * * @param $searchTerms * @param $roles * @param $adminId * @return array|mixed */ public function prepareSearchAllCreated($searchTerms, $roles, $adminId) { // If user has root privileges, get all the plans that were created. // Otherwise just get the plans created with administrator privilege. $adminList = []; $roleName = ''; if (in_array('root', $roles)) { $userId = 0; $roleName = 'root'; } // Display selected creator of the plan if (isset($adminId)) { $userId = $adminId; } // Administrators who created plans $admins = $this->userApi->getAllUsersByRole(['root', 'administrator']); // Set up dropdown list of all admins $adminsList = Tools::getUsersDropdrownOptions($admins, 'admin'); $columns = ['description', 'first_name', 'last_name', 'status', 'created_at', 'updated_at', 'edit']; $results = $this->tablesApi->searchPlans($searchTerms, $columns); $results += ['userId' => $userId, 'role' => $roleName, 'adminsList' => $adminsList]; return $results; }
} // navigation commands for tables, if necessary if ($stats['count'] > TABLES_PER_PAGE) { $home = 'tables/'; if ($context['with_friendly_urls'] == 'Y') { $prefix = $home . 'index.php/'; } elseif ($context['with_friendly_urls'] == 'R') { $prefix = $home; } else { $prefix = $home . '?page='; } $context['page_menu'] += Skin::navigate($home, $prefix, $stats['count'], TABLES_PER_PAGE, $page); } // query the database and layout that stuff $offset = ($page - 1) * TABLES_PER_PAGE; if (!($text = Tables::list_by_date($offset, TABLES_PER_PAGE, 'full'))) { $context['text'] .= '<p>' . i18n::s('No table has been created yet.') . '</p>'; } elseif (is_array($text)) { $context['text'] .= Skin::build_list($text, 'decorated'); } } // page tools if (Surfer::is_associate()) { $context['page_tools'][] = Skin::build_link('tables/import.php', i18n::s('Import'), 'basic'); $context['page_tools'][] = Skin::build_link('tables/check.php', i18n::s('Maintenance'), 'basic'); } // page extra content $cache_id = 'tables/index.php#extra'; if (!($text = Cache::get($cache_id))) { // side bar with the list of most recent pages if ($items =& Articles::list_by('publication', 0, COMPACT_LIST_SIZE, 'compact')) {
/** * list newest tables for one anchor * * Example: * [php] * include_once 'tables/tables.php'; * $items = Tables::list_by_date_for_anchor(0, 10, '', 'section:12'); * $context['text'] .= Skin::build_list($items, 'compact'); * [/php] * * @param int the id of the anchor * @param int the offset from the start of the list; usually, 0 or 1 * @param int the number of items to display * @param string the list variant, if any * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon) */ public static function list_by_date_for_anchor($anchor, $offset = 0, $count = 20, $variant = 'no_anchor') { global $context; // the request $query = "SELECT * FROM " . SQL::table_name('tables') . " WHERE (anchor LIKE '" . SQL::escape($anchor) . "') " . " ORDER BY edit_date DESC, title LIMIT " . $offset . ',' . $count; // the list of tables $output = Tables::list_selected(SQL::query($query), $variant); return $output; }
public function arg() { $string = \Tables::getString($this->obj->id); $ir = "i8* getelementptr inbounds ([{$string->size} x i8]* @.str{$string->id}, i32 0, i32 0)"; return $ir; }
{ $this->response = ''; } function add($newtext) { $this->response .= $newtext; } function __destruct() { unset($this->response); } } $response = new UpdateResponse(); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); require_once EASYWIDIR . '/stuff/methods/class_tables.php'; $tables = new Tables($dbConnect['db']); $response->add('Adding tables if needed.'); $tables->createMissingTables(); $response->add('Repairing tables if needed.'); $tables->correctTablesStatus(); $tables->correctExistingTables(); foreach ($tables->getExecutedSql() as $change) { $response->add($change . '<br>'); } $response->add('Fixing data entries if needed.'); include EASYWIDIR . '/stuff/methods/tables_entries_repair.php'; $template_file = $response->response; } else { if ($ui->st('d', 'get') == 're') { $sprache = getlanguagefile('settings', $user_language, $resellerLockupID); $gssprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
public function override_toggles($collection_id) { global $db, $form; $table = new Tables(); //start toggle_products form $form->start("variations.php?override={$collection_id}", false, "toggle_products"); //get collection variation ids using collection id (limit 1) $collection = $db->select("collections", "id='{$collection_id}'", "variation_ids", 1); //seperate variation ids (array explode) $variation_ids = explode(";;", $collection['variation_ids']); //for each variation get name & options $form->input("collection id", "collection_id", "text", $collection_id, true); foreach ($variation_ids as $key => $v_id) { $form->input("variation id", "variation_ids[]", "text", $v_id, true); //get variation name & options (limit 1) $variation = $db->select("variations", "id='{$v_id}'", 'name,options', 1); //seperate variation options $variation_options = explode(";;", $variation['options']); //count options $options_count = count($variation_options); //start table making header variation name with colspan = option count $table->start($variation['name'], "option_toggles"); $table->head($variation['name'], $options_count); //start toggle row echo "<tr>"; //for each option make cell include option toggle with name = variationsid[] foreach ($variation_options as $key => $option) { //default to all checked $checked = 1; //create cell echo "<td>"; //create form toggle input $form->input($option, $v_id . "[{$key}]", "toggle", $checked); //end cell echo "</td>"; } //end toggle row echo "</tr>"; //end table $table->end(); } //end form $form->end(); }
<td></td> <td></td> <td> <?php echo Tables::button("pencil", "turquoise", null, "editar", Label::editar); ?> <?php echo Tables::button("envelope", "hole", null, "enviar_correo", Label::enviar_correo_participantes); ?> <?php echo Tables::button("users", "wisteria", null, "participantes", Label::participantes); ?> <br> <?php echo Tables::button("clock-o", "orange", null, "posponer", Label::posponer); ?> <?php echo Tables::button("calendar-o", "pumpkin", null, "suspender", Label::suspender); ?> <?php echo Tables::button("calendar-times-o", "pomegranate", null, "cancelar", Label::cancelar); ?> </td> </tr> </tbody>--> </table> </div> </section> <?php };
public function analyze($ast, $parent = NULL) { /* holds the name of the currently compiled function */ $function = ""; foreach ($ast as $i => $node) { /* set the function name in the objects */ if ($node instanceof \Parser\Parsers\FunctionDefinition) { $function = $node->name; $node->function = $node->name; } elseif (!empty($node->function)) { $function = $node->function; } else { if (isset($node->name) && $node->name == "extern") { continue; } elseif (!empty($function)) { $node->function = $function; } else { if (!empty($parent->function)) { $node->function = $parent->function; } elseif (!empty($function)) { $node->function = $function; } } } /* set the arguments as local variables */ if ($node instanceof \Parser\Parsers\FunctionDefinition && count($node->arguments) > 0) { foreach ($node->arguments as $arg) { \Tables::addLocalVariable($function, $arg->name); } } if ($node instanceof \Parser\Parsers\Assignment) { /* deal with assignments */ if (is_object($node->content)) { if (\Tables::localVariable($node->function, $node->name)) { $var =& \Tables::updateLocalVariable($node->function, $node->name); } else { $var =& \Tables::addLocalVariable($node->function, $node->name); } $var->type[$node->line] = \Tables::I32; continue; } switch (\Misc::baseClass($node->content[0])) { case "String": $type = \Tables::STRING; break; case "Integer": $type = \Tables::I32; break; case "Addition": case "Subtraction": case "Multiplication": case "Division": $type = \Tables::I32; break; default: error("unknown assignment type '" . \Misc::baseClass($node->content[0]) . "' in line {$node->line}"); } if (\Tables::localVariable($node->function, $node->name)) { $var =& \Tables::updateLocalVariable($node->function, $node->name); } else { $var =& \Tables::addLocalVariable($node->function, $node->name); } $var->type[$node->line] = $type; } elseif (!$node instanceof \Parser\Parsers\Variable && count($node->content) > 0) { /* analyze recursively if needed */ if ($node instanceof \Parser\Parsers\FunctionDefinition && !empty($node->arguments)) { foreach ($node->arguments as $arg) { $arg->function = $function; } } $this->analyze($node->content, $node); } elseif ($node instanceof \Parser\Parsers\Variable) { /* do type inference based on printf */ if ($parent instanceof \Parser\Parsers\Call) { if ($parent->name == "printf") { $matches = array(); preg_match_all("/%[scdiu]/", $ast[0]->string, $matches); $format = substr($matches[0][$i - 1], -1); $type = 0; switch ($format) { case 'd': case 'i': case 'c': $type |= \Tables::I32; break; case 's': $type |= \Tables::STRING; } $var =& \Tables::updateLocalVariable($node->function, $node->name); if ($var == NULL) { continue; } $node->type[$node->line] = $type; } } } } }
if (is_object($anchor)) { $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span'); } // the submit button $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // the title of the table if (isset($item['title'])) { $context['text'] .= Skin::build_block($item['title'], 'title'); } // display the full text $context['text'] .= Skin::build_block($item['description'], 'description'); // execute the query string to build the table if (isset($item['query']) && $item['query']) { $context['text'] .= Tables::build($item['id'], 'sortable'); } // display the query string, if any if (isset($item['query']) && $item['query']) { $context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n"; } // details $details = array(); // information on uploader if (Surfer::is_member() && $item['edit_name']) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } // all details if ($details) { $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>' . "\n"; }
} } if ($f_cur !== $f_max) { for ($i = $f_cur; $i <= $f_max; $i++) { echo "<td></td>"; } echo "</tr>"; } $table->end(); } } else { $html->title("Order Uploads", null, "left"); echo "<hr />"; $customers = $db->select("users_in_roles INNER JOIN users ON users_in_roles.user_id=users.id", "`role_id`='4'", "users.id,users.username"); $nonarchived = $db->select("uploads INNER JOIN orders ON uploads.order_id=orders.id", "orders.`archive` = '0'", "DISTINCT uploads.order_id"); $table = new Tables(); if ($customers and $nonarchived) { $table->start("orders_list", "table-bordered"); $table->head("Customer ID,Order #/Name,Uploads,sm"); foreach ($customers as $customer) { $oids = $db->select("uploads INNER JOIN orders ON uploads.order_id=orders.id", "uploads.`user_id`='" . $customer['id'] . "' AND orders.`archive` = '0'", "DISTINCT uploads.order_id"); if ($oids) { $count['orders'] = count($oids); $cur = 1; foreach ($oids as $oid) { echo "<tr>"; if ($cur == 1) { echo "<td rowspan='" . $count['orders'] . "'>" . $customer['username'] . "</td>"; } echo "<td>" . $order[$oid['order_id']] . "</td>"; $uploads = count($db->select("uploads", "`user_id`='" . $customer['id'] . "' AND `order_id`='" . $oid['order_id'] . "'"));
</th> <th style = "width: 10%"><?php echo Label::fecha; ?> </th> <th style = "width: 10%"><?php echo Label::acciones; ?> </th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td> <?php echo Tables::button("star-o", "pomegranate", null, "seguir", Label::dejar_seguir); ?> </td> </tr> </tbody> </table> </div> </section> <?php };
/** * render a dynamic table * * @param string the table content * @param string the variant, if any * @return string the rendered text **/ public static function render_dynamic_table($id, $variant = 'inline') { global $context; // refresh on every page load Cache::poison(); // get actual content include_once $context['path_to_root'] . 'tables/tables.php'; // use SIMILE Exhibit if ($variant == 'filter') { // load the SIMILE Exhibit javascript library in shared/global.php $context['javascript']['exhibit'] = TRUE; // load data $context['page_header'] .= "\n" . '<link href="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_json') . '" type="application/json" rel="exhibit/data" />'; // exhibit data in a table $text = '<div ex:role="exhibit-view" ex:viewClass="Exhibit.TabularView" ex:columns="' . Tables::build($id, 'json-labels') . '" ex:columnLabels="' . Tables::build($id, 'json-titles') . '" ex:border="0" ex:cellSpacing="0" ex:cellPadding="0" ex:showToolbox="true" ></div>' . "\n"; // allow for filtering $facets = '<div class="exhibit-facet">' . '<div class="exhibit-facet-header"><span class="exhibit-facet-header-title">' . i18n::s('Filter') . '</span></div>' . '<div class="exhibit-facet-body-frame" style="margin: 0 2px 1em 0;">' . '<div ex:role="facet" ex:facetClass="TextSearch" style="display: block;"></div>' . '</div></div>'; // facets from first columns $facets .= Tables::build($id, 'json-facets'); // filter and facets aside $context['components']['boxes'] .= $facets; // build sparkline } elseif ($variant == 'bars') { $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=0⪆0.5" alt="" />'; // buid a Flash chart } elseif ($variant == 'chart') { // split parameters $attributes = preg_split("/\\s*,\\s*/", $id, 4); // set a default size if (!isset($attributes[1])) { $attributes[1] = 480; } if (!isset($attributes[2])) { $attributes[2] = 360; } // object attributes $width = $attributes[1]; $height = $attributes[2]; $flashvars = ''; if (isset($attributes[3])) { $flashvars = $attributes[3]; } // allow several charts to co-exist in the same page static $chart_index; if (!isset($chart_index)) { $chart_index = 1; } else { $chart_index++; } // get data in the suitable format $data = Tables::build($attributes[0], 'chart'); // load it through Javascript $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf'; $text = '<div id="table_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n"; Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "table_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"table_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function table_chart_' . $chart_index . '() {' . "\n" . ' return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n"); // build sparkline } elseif ($variant == 'line') { $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=2&gap=0.0" alt="" />'; // we do the rendering ourselves } else { $text = Tables::build($id, $variant); } // put that into the web page return $text; }