/** * Show the list of contact fields in edit contact page * * @global array $company_fields List of contact fields * @param <type> $contact_id * * @since 0.1 */ function _rolo_show_edit_contact_form($contact_id) { global $contact_fields; $rolo_tab_index = 1000; $contact = get_post_meta($contact_id, 'rolo_contact'); $contact = $contact[0]; ?> <form action="" method="post" class="uniForm inlineLabels" id="contact-edit"> <div id="errorMsg"> <h3><?php _e('Campos obrigatórios não estão preenchidos.', 'rolopress'); ?> </h3> </div> <div id="addContact"> <div id="frameContainer"> <?php // Get one of the nine frames possible $pframe = get_post_meta($contact_id, 'rolo_contact_framename', true); $importance = $pframe[strlen($pframe) - 1]; $i = $pframe[strlen($pframe) - 2]; $previous = get_previous($i); $next = get_next($i); $previous_imp = get_previous($importance); $next_imp = get_next($importance); if (!empty($_GET['imp']) && $_GET['imp'] > 0 && $_GET['imp'] < 4) { $importance = $_GET['imp']; switch ($importance) { case 1: $next_imp = 2; $previous_imp = 3; break; case 3: $next_imp = 1; $previous_imp = 2; break; default: $next_imp = $importance + 1; $previous_imp = $importance - 1; break; } } if (!empty($_GET['pframe']) && $_GET['pframe'] > 0 && $_GET['pframe'] < 4) { $previous = get_previous($_GET['pframe']); $next = get_next($_GET['pframe']); $pframe = 'frame' . $_GET['pframe'] . $importance; } $frame_number = $pframe; global $_wp_additional_image_sizes; $w = $_wp_additional_image_sizes[$frame_number]['width']; $h = $_wp_additional_image_sizes[$frame_number]['height']; $current_pframe = $pframe[strlen($pframe) - 2]; ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script> <div id="contact"> <div class="photo" id="<?php echo $frame_number; ?> "> <a href="<?php echo $link; ?> "> <span class="droparea spot <?php echo $frame_number; ?> " data-width="<?php echo $w; ?> " data-height="<?php echo $h; ?> " data-type="jpg" data-crop="true" style="width: <?php echo $w; ?> px; height: <?php echo $h; ?> px"></span> <span class="<?php echo $frame_number; ?> " style="z-index: -100;"> <?php echo get_the_post_thumbnail($contact_id, $frame_number); // AQUI É ONDE É POSTA A FOTO ?> </span> </a> <img src="<?php echo get_bloginfo('template_url') . '/library/images/frames/' . $frame_number . '.png'; ?> " alt=""> <div class="title"> <?php the_title(); ?> </div> </div> <span class="info">Use as setas para escolher a moldura.</span><br/> <a id="change_frame_left" href="?id=<?php echo $contact_id; ?> &pframe=<?php echo $previous; ?> "> <img src="<?php echo get_bloginfo('stylesheet_directory'); ?> /img/esquerda.png"> </a> <a id="change_frame_right" href="?id=<?php echo $contact_id; ?> &pframe=<?php echo $next; ?> "> <img src="<?php echo get_bloginfo('stylesheet_directory'); ?> /img/direita.png"> </a> <br/> <span class="info">O quão importante é para si este contacto?</span><br/> <?php if ($importance != 1) { ?> <a id="change_frame_left" href="?id=<?php echo $contact_id; ?> &pframe=<?php echo $current_pframe; ?> &imp=<?php echo $previous_imp; ?> "> <img src="<?php echo get_bloginfo('stylesheet_directory'); ?> /img/minus.png"> </a> <?php } ?> <?php if ($importance != 3) { ?> <a id="change_frame_right" href="?id=<?php echo $contact_id; ?> &pframe=<?php echo $current_pframe; ?> &imp=<?php echo $next_imp; ?> "> <img src="<?php echo get_bloginfo('stylesheet_directory'); ?> /img/plus_s.png"> </a> <?php } ?> </div> <!-- close div contact --> <script src="http://simplephone.me/wp-content/themes/rolopress-core/library/js/droparea.js" type="text/javascript"></script> <script> jQuery('.droparea').droparea({ 'post' : 'http://simplephone.me/wp-content/themes/rolopress-core/library/includes/upload.php', 'init' : function(r){ //console.log('my init',r); }, 'start' : function(r){ //console.log('my start',r); }, 'error' : function(r){ //console.log('my error',r); }, 'complete' : function(r){ console.log('my complete',r); jQuery("#filename").attr("value", r.filename_original); } }); </script> </div> <!-- end frameContainer --> <div id="fieldContainer"> <fieldset class="inlineLabels"> <?php foreach ($contact_fields as $contact_field) { if (function_exists($contact_field['setup_function'])) { call_user_func_array($contact_field['setup_function'], array($contact_field['name'], &$rolo_tab_index, $contact_id)); } else { $name = 'rolo_contact_' . $contact_field['name']; $current_value = $contact[$name]; $class = $contact_field['class']; $mandatory_class = ''; if ($contact_field['mandatory'] == true) { $mandatory_class = ' mandatory'; } ?> <div class="ctrlHolder <?php echo $contact_field['class']; echo $mandatory_class; ?> "> <li><label for="<?php echo $name; ?> "> <?php if ($contact_field['mandatory'] == true) { echo '<em>*</em>'; } echo $contact_field['title']; ?> </label></li> <?php if (isset($contact_field['prefix']) == true) { echo '<span class="prefix '; echo $contact_field['name']; echo '">'; echo $contact_field['prefix']; echo '</span>'; $class = $contact_field['class'] . " " . "input-prefix"; } ?> <li> <input type="text" name="<?php echo $name; ?> " value="<?php echo $current_value; ?> " size="55" tabindex="<?php echo $rolo_tab_index; ?> " class="textInput <?php echo $class; ?> " /></li> </div> <?php $rolo_tab_index++; } } ?> </fieldset> </div> <div class="buttonHolder"> <input type="hidden" name="contact_id" value="<?php echo $contact_id; ?> " /> <input type="hidden" id="framename" name="framename" value="<?php echo $frame_number; ?> " /> <input type="hidden" id="filename" name="filename" value="" /> <input type="hidden" name="rp_edit_contact" value="edit_contact" /> <button type="submit" name="submit" id="edit_contact" class="submitButton" tabindex="<?php echo $rolo_tab_index++; ?> " ><?php _e('Editar Contacto', 'rolopress'); ?> </button> </div> </form> <?php }
public static function _fix_data() { $date = Mongo_db::date(); // We need to generate a large amount of varied data but we need // to ensure that is always the same. $surveys = array(1, 2, 3, 4, 5); $no_reply_x5 = array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // once every 17 $amount_no_reply = array(0, 0, 1, 0, 0, 1, 0, 2, 0, 0, 0, 2, 0, 3, 0, 0, 0, 1, 3, 0, 0, 0); $final_status = array(Call_task_status::SUCCESSFUL, Call_task_status::NO_CONSENT, Call_task_status::NUMBER_CHANGE, Call_task_status::DISCARD, Call_task_status::INVALID_NUMBER, Call_task_status::SUCCESSFUL, Call_task_status::SUCCESSFUL, Call_task_status::SUCCESSFUL, Call_task_status::DISCARD, Call_task_status::SUCCESSFUL, Call_task_status::SUCCESSFUL, Call_task_status::NO_CONSENT, Call_task_status::SUCCESSFUL, Call_task_status::SUCCESSFUL, Call_task_status::NO_CONSENT, Call_task_status::SUCCESSFUL); // Clean db! self::$CI->mongo_db->dropDb('aw_datacollection_test'); ////////////////////////////////////////////////////////////// // Not assigned: for ($total_ct = 1; $total_ct <= 10000; $total_ct++) { $resp = array('ctid' => increment_counter('call_task_ctid'), 'number' => (string) (1000000000000 + $total_ct), 'created' => $date, 'updated' => $date, 'assigned' => NULL, 'author' => 1, 'assignee_uid' => NULL, 'survey_sid' => get_next($surveys), 'activity' => array()); self::$CI->mongo_db->insert(Call_task_model::COLLECTION, $resp); } ////////////////////////////////////////////////////////////// // Assigned // 30000 per user (3 users) for ($assignee = 1; $assignee <= 3; $assignee++) { $status = array('message' => NULL, 'author' => $assignee, 'created' => $date); // Resolved 20000 for ($total_ct = 1; $total_ct <= 20000; $total_ct++) { $resp = array('ctid' => increment_counter('call_task_ctid'), 'number' => (string) (1000000000000 + $assignee * 100000 + $total_ct), 'created' => $date, 'updated' => $date, 'assigned' => $date, 'author' => 1, 'assignee_uid' => $assignee, 'survey_sid' => get_next($surveys)); // Some no-reply. if (get_next($no_reply_x5)) { $status['code'] = Call_task_status::NO_REPLY; for ($i = 0; $i < Call_task_status::THRESHOLD_NO_REPLY; $i++) { $resp['activity'][] = $status; } } else { for ($i = 0; $i < get_next($amount_no_reply); $i++) { $status['code'] = Call_task_status::NO_REPLY; $resp['activity'][] = $status; } $status['code'] = get_next($final_status); $resp['activity'][] = $status; } self::$CI->mongo_db->insert(Call_task_model::COLLECTION, $resp); } // Unresolved 10000 for ($total_ct = 1; $total_ct <= 10000; $total_ct++) { $resp = array('ctid' => increment_counter('call_task_ctid'), 'number' => (string) (1000000000000 + $assignee * 1000000 + $total_ct), 'created' => $date, 'updated' => $date, 'assigned' => $date, 'author' => 1, 'assignee_uid' => $assignee, 'survey_sid' => get_next($surveys)); for ($i = 0; $i < get_next($amount_no_reply); $i++) { $status['code'] = Call_task_status::NO_REPLY; $resp['activity'][] = $status; } $status['code'] = Call_task_status::CANT_COMPLETE; $resp['activity'][] = $status; self::$CI->mongo_db->insert(Call_task_model::COLLECTION, $resp); } } // Add index: ctid. self::$CI->mongo_db->addIndex(Call_task_model::COLLECTION, array('ctid' => 1)); // Add index: survey_sid. self::$CI->mongo_db->addIndex(Call_task_model::COLLECTION, array('survey_sid' => 1)); }
echo "<h2>{$title}</h2>\n"; form_begin('tag_edit', $_SERVER['PHP_SELF']); hidden_input('posted', 1); hidden_input('tag', $tag); select_tag_group($tag_group); select_tag_type($tag_type); text_input("GEDCOM :", 10, 'gedcom_tag', $gedcom_tag); text_input("Tag name :", 80, 'tag_name', $tag_name); text_input("Tag label:", 80, 'tag_label', $tag_label); form_submit(); form_end(); echo "</body>\n</html>\n"; } else { $tag = $_POST['tag']; $tag_group = $_POST['tag_group']; $tag_name = $_POST['tag_name']; $gedcom_tag = $_POST['gedcom_tag']; $tag_label = $_POST['tag_label']; $tag_type = $_POST['tag_type']; if (!$tag) { // insert new tag pg_query("BEGIN"); $tag = get_next('tag'); pg_query("\n INSERT INTO tags (\n tag_id,\n tag_group_fk,\n tag_type_fk,\n tag_name,\n gedcom_tag,\n tag_label\n )\n VALUES (\n {$tag},\n {$tag_group},\n {$tag_type},\n '{$tag_name}',\n '{$gedcom_tag}',\n '{$tag_label}'\n )\n "); pg_query("COMMIT"); } else { // modify existing tag pg_query("\n UPDATE tags SET\n tag_group_fk = {$tag_group},\n tag_name = '{$tag_name}',\n gedcom_tag = '{$gedcom_tag}',\n tag_label = '{$tag_label}',\n tag_type_fk = {$tag_type}\n WHERE tag_id = {$tag}"); } header("Location: {$app_root}/tag_manager.php"); }
$n = trim(fgets($handle)); $a = []; $counter = $n; for ($i = 0; $i < $n; $i++) { $a[] = $i; } $thrower = 0; function get_next($array, $key) { $currentKey = key($array); while ($currentKey !== null && $currentKey != $key) { next($array); $currentKey = key($array); } return next($array); } while ($counter > 1) { if ($counter % 2 == 0) { $oposite = $counter / 2; unset($a[$thrower + $oposite]); $counter--; $thrower = get_next($a, $thrower); } else { unset($a[$thrower]); $counter--; $thrower = get_next($a, $thrower); } } echo $a[0]; } fclose($handle);
What’s On </h1> </header> <div class="border-t border-b blog-nav u-textCenter u-cf"> <?php $month = ''; $year = ''; $today = date('d M'); // try to get the date from the url if (isset($_GET['month']) && isset($_GET['year'])) { $current = array("month" => $_GET['month'], "year" => $_GET['year']); } else { $current = array("month" => date('m'), "year" => date('Y')); } $next = get_next($current); $previous = get_previous($current); // example: returns '14' from 2014 $custom_prev_year = substr($previous['year'], -2); $custom_current_year = substr($current['year'], -2); $custom_next_year = substr($next['year'], -2); ?> <div class="blog-nav__link"> <span class="btn btn-skin u-inlineBlock u-valign-middle"> <a href="<?php echo get_permalink(22); ?> ?month=<?php echo $previous['month']; ?> &year=<?php