add_image = WP_PLUGIN_URL . '/' . WP_PLUGIN_FOLDER . '/img/plus_16.png'; $this->del_image = WP_PLUGIN_URL . '/' . WP_PLUGIN_FOLDER . '/img/block_16.png'; $this->help_image = WP_PLUGIN_URL . '/' . WP_PLUGIN_FOLDER . '/img/bugsqa_16.png'; $this->new_window_image = WP_PLUGIN_URL . '/' . WP_PLUGIN_FOLDER . '/img/new_window_icon.gif'; $this->calendar_image = site_url() . '/wp-admin/images/date-button.gif'; } public function setRelations($module) { $this->parent_key = false; $this->parent_module = false; $this->childs_modules_array = false; $this->childs_modules = false; $this->relation_notif_config = false; if (isset($module['relation_notif_config'])) { $this->relation_notif_config = $module['relation_notif_config']; if ($module['relation_notif_config']['relationships']['parent'] !== null) { $ar_parent = $module['relation_notif_config']['relationships']['parent']; foreach ($ar_parent as $parkey => $parsubarr) { $this->parent_key = $parkey; } } if ($module['relation_notif_config']['relationships']['childs'] !== null) { $this->childs_modules_array = $module['relation_notif_config']['relationships']['childs']; $this->childs_modules = array(); foreach ($this->applications as $key => $application) { foreach ($this->childs_modules_array as $chikey => $chisubarr) { if (isset($application['modules'][$chikey])) { $this->childs_modules[] = $application['modules'][$chikey]; } } } } } } /**/ public function setFieldsBox($key, $metabox_obj, $previewbtn = false) { global $post; if (isset($metabox_obj['positioning'])) { $this->setBoxByTabsNew($key, $metabox_obj['positioning'], $previewbtn); } else if (isset($metabox_obj['fields'])) { $this->setBoxByFields($key, $metabox_obj['fields']); } } public function setBoxByTabsNew($key, $positioning, $previewbtn = false) { global $post; if (count($positioning['topbar']) > 0) { $this->setBoxTopBar($key, $positioning['topbar'], $previewbtn); } if (count($positioning['main']) > 0) { $this->setBoxByTabsMain($key, $positioning); } if (isset($positioning['tabs']) and count($positioning['tabs']) > 0) { $this->setBoxByTabsTabs($key, $positioning); } } public function setBoxTopBar($key, $postopbar, $previewbtn = false) { global $post, $current_user; $this->cururl = $_SERVER["REQUEST_URI"]; $str.=' '; $usid = $current_user->ID; $isadmin = current_user_can('administrator'); $usdislpayname = $current_user->display_name; $str.=' '; $str.='
'; $str.='

'; echo $str; } public function setBoxByTabsMain($key, $positioning) { global $post; $str = '
'; $c = 0; $ctotal = count($positioning['main']); foreach ($positioning['main'] as $fieldset) { $str.=$this->setFieldSet($key, $positioning, $fieldset); } $str.="
"; echo $str; } public function setBoxByTabsTabs($key, $positioning) { global $post; $strhead = ' '; $strbody.=' '; /* '; */ /*
azaz
sdsds
fgfhfh
klklkl
*/ echo $strhead . $strbody; /* echo '
'; if(count($positioning['tabs'])>1){ echo ' '; } echo '
'; foreach($positioning['tabs'] as $subkey => $tab){ echo '
    '; $c=0; $ctotal=count($positioning['main']); foreach($tab['items'] as $fieldset){ $c++; $class='apm_li_inline'; if($c==$ctotal){ $class='apm_li_inline_last'; } echo '
      '; $pos='inline'; if(count($fieldset )==1){ $pos='regular'; } $total_width=0; foreach($fieldset as $field){ $width=10; if(isset($this->default_fields[$field])){ $f=$this->default_fields[$field]; isset($f['width']) ? $width=intval($f['width']): $width=10; } $total_width+=$width; } foreach($fieldset as $field){ $this->setField($field,'
    • ','
    • ',$pos,$total_width); } echo '
    '; } echo '
'; } echo '
'; */ } public function setFieldSet($key, $positioning, $fieldset) { global $post; $total_width = 0; $str = '
'; foreach ($fieldset as $field) { $width = 1; if (isset($this->default_fields[$field])) { $f = $this->default_fields[$field]; isset($f['width']) ? $width = $f['width'] : $width = 1; } $total_width+=$width; } if (count($fieldset) == 1) { $pos = 'regular'; } // $total_width=intval($total_width); $width_rate = 12 / $total_width; foreach ($fieldset as $field) { $width = 1; if (isset($this->default_fields[$field])) { $f = $this->default_fields[$field]; isset($f['width']) ? $width = $f['width'] : $width = 1; } $width_ra = intval($width * $width_rate); $str.='
'; $str.=$this->setFieldNew($field, $pos, $total_width); $str.='
'; } //echo "
".$total_width; $str.='
'; return $str; } public function setFieldNew($field, $pos, $total_width) { global $post, $meta_marker, $oThis; if (isset($this->default_fields[$field])) { $f = $this->default_fields[$field]; $f['field'] = $field; isset($f['field_type']) ? $f['field_type'] = $f['field_type'] : $f['field_type'] = 'textfield'; isset($f['default']) ? $f['default'] = $f['default'] : $f['default'] = ''; isset($f['child_second_parent']) ? $f['child_second_parent'] = $f['child_second_parent'] : $f['child_second_parent'] = ''; isset($f['child_key']) ? $f['child_key'] = $f['child_key'] : $f['child_key'] = ''; isset($f['label_position']) ? $f['label_position'] = $f['label_position'] : $f['label_position'] = 'left'; isset($f['description']) ? $f['description'] = $f['description'] : $f['description'] = ''; isset($f['info']) ? $f['info'] = $f['info'] : $f['info'] = ''; isset($f['help']) ? $f['help'] = $f['help'] : $f['help'] = ''; isset($f['hide_label']) ? $f['hide_label'] = $f['hide_label'] : $f['hide_label'] = ''; isset($f['image_resize']) ? $f['image_resize'] = $f['image_resize'] : $f['image_resize'] = false; isset($f['img_config']) ? $f['img_config'] = $f['img_config'] : $f['img_config'] = false; isset($f['label_width']) ? $f['label_width'] = $f['label_width'] : $f['label_width'] = 100; isset($f['width']) ? $f['widthli'] = $f['width'] : $f['widthli'] = 10; isset($f['width']) ? $f['width'] = ' width:' . ($f['width'] * 10 ) . '%; ' : $f['width'] = ''; isset($f['img_width']) ? $f['img_width'] = intval($f['img_width']) : $f['img_width'] = false; isset($f['show_input']) ? $f['show_input'] = intval($f['show_input']) : $f['show_input'] = false; isset($f['img_height']) ? $f['img_height'] = intval($f['img_height']) : $f['img_height'] = false; isset($f['label_width_perc']) ? $f['label_width_perc'] = intval($f['label_width_perc']) : $f['label_width_perc'] = 0; isset($f['options']) ? $f['options'] = $f['options'] : $f['options'] = array(); isset($f['html']) ? $f['html'] = $f['html'] : $f['html'] = ""; isset($f['use_none']) ? $f['use_none'] = $f['use_none'] : $f['use_none'] = ""; isset($f['maxlength']) ? $f['maxlength'] = $f['maxlength'] : $f['maxlength'] = ""; isset($f['label_type']) ? $f['label_type'] = $f['label_type'] : $f['label_type'] = 'regular'; if ($global_label_type !== false) { $f['label_type'] = $global_label_type; } isset($f['allow_multi_files']) ? $f['allow_multi_files'] = $f['allow_multi_files'] : $f['allow_multi_files'] = false; isset($f['allow_files_description']) ? $f['allow_files_description'] = $f['allow_files_description'] : $f['allow_files_description'] = false; isset($f['field_config']) ? $f['field_config'] = $f['field_config'] : $f['field_config'] = ''; isset($f['required']) ? $f['required'] = $f['required'] : $f['required'] = false; isset($f['restrict_format']) ? $f['restrict_format'] = $f['restrict_format'] : $f['restrict_format'] = false; if ($field !== "post_content" and $field !== "post_title" and $field !== "post_status") { $field_value = get_post_meta($post->ID, $field . $meta_marker, true); } else { if ($field == "post_content") { $field_value = $post->post_content; } if ($field == "post_title") { $field_value = $post->post_title; } if ($field == "post_status") { $field_value = $post->post_status; } } empty($field_value) ? $value = $default : $value = $field_value; $post_type = get_post_type($post); $f['value'] = $field_value; ///DEFINE PARENT ID, in case we need it... Only if we defined in module config, the follow: /* 'define_parent'=>array( 'parent_post_type'=>'fgl_companies', 'parent_post_field'=>'fgl_company_parent' ), * * */ $parent_id = 0; foreach ($this->applications as $key => $application) { if (isset($application['modules'][$post_type])) { $parent_post_type = $application['modules'][$post_type]['define_parent']['parent_post_type']; $parent_post_field = $application['modules'][$post_type]['define_parent']['parent_post_field']; if (isset($_GET['post'])) {//=is edit $parent_id = get_post_meta($post->ID, $parent_post_field . $meta_marker, true); } else if (isset($_GET['parent_id'])) { $parent_id = $_GET['parent_id']; } if (isset($application['modules'][$post_type]['module_new_categories'])) {//=is edit $f['module_new_categories'] = $application['modules'][$post_type]['module_new_categories']; $f['app_categories'] = $application['categories']; } }; } //echo "//".$f['field_type']; switch ($f['field_type']) { case 'textfield': $str = $this->setBasicFieldNew($f, 'textfield'); break; case 'currencyfield': $str = $this->setBasicFieldNew($f, 'currencyfield'); break; case 'autoincrementfield': $str = $this->setBasicFieldNew($f, 'autoincrementfield'); break; case 'numberfield': $str = $this->setBasicFieldNew($f, 'numberfield'); break; case 'hiddenfield': $str = $this->setBasicFieldNew($f, 'hiddenfield'); break; case 'autocomplete': $str = $this->setBasicFieldNew($f, 'autocomplete'); break; case 'add_child': $str = $this->setAddChildNew($f); break; case 'photo': break; case 'autosuggest_multiselect': break; case 'convert_button': break; case 'action_button': $str = $this->setActionButtonNew($f); break; case 'categories_list': $str = $this->setCategoriesListNew($f); break; case 'auto_set_title': $str = $this->setBasicFieldNew($f, 'auto_set_title'); break; case 'created_by': $str = $this->setBasicFieldNew($f, 'created_by'); break; case 'created_date': $str = $this->setBasicFieldNew($f, 'created_date'); break; case 'modified_date': $str = $this->setBasicFieldNew($f, 'modified_date'); break; case 'displayfield': break; case 'checkbox': $str = $this->setBasicFieldNew($f, 'checkbox'); break; case 'select': $str = $this->setBasicFieldNew($f, 'select'); break; case 'radio': $str = $this->setBasicFieldNew($f, 'radio'); break; case 'html': $str = $this->setBasicFieldNew($f, 'html'); break; case 'comments': $str = $this->setBasicFieldNew($f, 'comments'); break; case 'textarea': $str = $this->setBasicFieldNew($f, 'textarea'); break; case 'uploadfield': $str = $this->setBasicFieldNew($f, 'uploadfield'); break; /* case 'team': $str=$this->setBasicFieldNew($f,'team'); break; */ /* case 'in_body_category_select': $str=$this->setBasicFieldNew($f,'in_body_category_select'); break; */ case 'richtexteditor': $str = $this->setBasicFieldNew($f, 'richtexteditor'); break; case 'childgrid': $str = $this->setChildGridNew($f); break; case 'childphotogrid': break; case 'userslist': $str = $this->setUserslistNew($f); // break; case 'datefield': $str = $this->setBasicFieldNew($f, 'datefield'); break; case 'assignee': $str = $this->setAssignmentsNew($f); // break; case 'notifications_rules': $str = $this->setBasicFieldNew($f, 'notifications_rules'); break; case 'notifications': $str = $this->setBasicFieldNew($f, 'notifications'); //$this->setNotifications($args); //$this->setNotificationsRules($args); break; default: //case 'in_body_category_select': $str = $this->setBasicFieldNew($f, $f['field_type']); // echo "///////////////////////"; // var_dump($oThis->extensions); // exit; break; } } return $str; } public function get_childtable($post_id, $post_type, $meta_key, $search, $field) { global $wpdb, $current_user, $meta_marker; // echo "///".$meta_marker."///"; if (current_user_can('administrator')) { $query = "SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id WHERE $wpdb->posts.post_type = '$post_type' AND $wpdb->postmeta.meta_key='" . $meta_key . $meta_marker . "' AND $wpdb->postmeta.meta_value='$post_id' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft') "; } else { $uid = $current_user->ID; $query = "SELECT DISTINCT post_title, post_name , ID, post_status, post_date, post_type, post_author FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->postmeta as metaprivacy ON $wpdb->posts.ID = metaprivacy.post_id INNER JOIN $wpdb->postmeta as metaassignee ON $wpdb->posts.ID = metaassignee.post_id WHERE $wpdb->posts.post_type = '$post_type' AND $wpdb->postmeta.meta_key='" . $meta_key . $meta_marker . "' AND $wpdb->postmeta.meta_value='$post_id' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft') AND ((post_author = $uid AND metaprivacy.meta_value = '1' AND metaprivacy.meta_key = '" . $meta_name . "set_privacy') OR ( metaprivacy.meta_value = '0' AND metaprivacy.meta_key = '" . $meta_name . "set_privacy') OR ( metaprivacy.meta_value = '2' AND metaprivacy.meta_key = '" . $meta_name . "set_privacy' AND post_author = $uid ) OR ( metaprivacy.meta_value = '2' AND metaprivacy.meta_key = '" . $meta_name . "set_privacy' AND metaassignee.meta_key = '" . $meta_name . "assign_to' AND metaassignee.meta_value = '$uid' )) "; } if ($search !== "") { $query .=" AND ($wpdb->posts.post_title LIKE '%" . $search . "%') "; } $query .=" ORDER BY post_title"; $posts = $wpdb->get_results($query); //echo $query; // var_dump($posts); $str = ""; $f = $this->default_fields[$field]; $field_config = $f['field_config']; $columns = array(); if (isset($field_config['columns'])) { $columns = $field_config['columns']; } if (count($posts) > 0) { foreach ($posts as $p) { $str.= ""; foreach ($columns as $columnar) { $column = $columnar['field']; $out = sprintf(' %s', esc_url(add_query_arg(array('post' => $p->ID, 'action' => 'edit'), 'post.php')), esc_html($p->post_title) ); $out .= sprintf(' %s', esc_url(add_query_arg(array('post' => $p->ID, 'action' => 'edit'), 'post.php')), '' ); $f = $this->default_fields[$column]; switch ($column) { case "post_title": $str.= '' . $out . ''; break; case "post_date": $h_time = mysql2date(__('Y/m/d'), $p->post_date); $str.= '' . $h_time . ''; break; case "post_status": $str.= '' . $p->post_status . ''; break; default: $meta = get_post_meta($p->ID, $column . $meta_marker, true); if ($meta !== '') { //userslist if (isset($f['field_type'])) { switch ($f['field_type']) {//setInBodyCategorySelect case "setInBodyCategorySelect": $taxonomies = $f['field_config']['category']; $t = get_term($meta, $taxonomies); $meta = $t->name; break; case "select": if (isset($f['field_config']['use_values']) and $f['field_config']['use_values'] == true) { $meta = $f['options'][$meta]; } else { $subpost = get_post($meta); $meta_t = $subpost->post_title; $meta = sprintf('%s', esc_url(add_query_arg(array('action' => 'edit', 'post' => $subpost->ID), 'post.php')), $meta_t ); $meta.=sprintf('%s', esc_url(add_query_arg(array('action' => 'edit', 'post' => $subpost->ID), 'post.php')), ' ' ); } break; case "autocomplete": $subpost = get_post($meta); $meta_t = $subpost->post_title; $meta = sprintf('%s', esc_url(add_query_arg(array('action' => 'edit', 'post' => $subpost->ID), 'post.php')), $meta_t ); $meta.=sprintf('%s', esc_url(add_query_arg(array('action' => 'edit', 'post' => $subpost->ID), 'post.php')), ' ' ); break; case "userslist": $user = get_users(array( 'include' => $meta )); $meta = $user[0]->display_name; break; case "assignee": $user = get_users(array( 'include' => $meta )); $meta = $user[0]->display_name; break; } //echo var_dump($subpost); } } $str.= '' . $meta . ''; break; } } $str.= ""; } } else { $nbcol = count($columns); $str = "No child items"; } $a = array( str => $str ); echo json_encode($a); die(); } public function setCategoriesLi($cat, $parent, $t = '', $pcat, $lvl = 0) { $args = array( 'taxonomy' => $cat, 'hide_empty' => 0, 'parent' => $parent, 'orderby' => 'name', 'order' => 'ASC' ); $categs = get_categories($args); if ($t == "sub") { $str = '