function get_featured_image($postid) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $img = qa_db_postmeta_get($postid, 'featured_image'); if (!empty($img)) { return '<img class="image-preview" id="image-preview" src="' . Q_THEME_URL . '/uploads/' . $img . '" />'; } return false; }
function doctype() { qa_html_theme_base::doctype(); require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; // Custom Meta(title,description,keywords) if ($this->template == 'question' and qa_opt('useo_meta_editor_enable')) { $metas = json_decode(qa_db_postmeta_get($this->content['q_view']['raw']['postid'], 'useo-meta-info'), true); $this->meta_title = @$metas['title']; $this->meta_description = @$metas['description']; $this->meta_keywords = @$metas['keywords']; } // Generate Social Meta Tags $page_url = @$this->content['canonical']; if (!empty($this->meta_description)) { $description = $this->meta_description; } else { $description = @$this->content['description']; } if (!empty($this->meta_title)) { $title = $this->meta_title; } else { $title = @$this->content['q_view']['raw']['title']; } if ($this->template == 'question') { if (qa_opt('useo_social_enable_editor')) { $this->social_metas = json_decode(qa_db_postmeta_get($this->content['q_view']['raw']['postid'], 'useo-social-info'), true); if (count($this->social_metas)) { foreach ($this->social_metas as $index => $variable) { $this->metas[$index]['content'] = $variable; $this->metas[$index]['type'] = ''; } } } if (qa_opt('useo_social_og_enable_auto')) { // Open Graph // site name $this->metas['og-sitename']['content'] = @$this->content['site_title']; $this->metas['og-sitename']['type'] = 'property="og:site_name"'; // title $this->metas['og-title']['content'] = $title; $this->metas['og-title']['type'] = 'property="og:title"'; // description $gl_length = qa_opt('useo_social_og_desc_length'); if ($gl_length <= 0) { $gl_length = 140; } $this->metas['og-description']['content'] = useo_get_excerpt($description, 0, $gl_length); $this->metas['og-description']['type'] = 'property="og:description"'; // Type $this->metas['og-type']['content'] = 'website'; $this->metas['og-type']['type'] = 'property="og:type"'; // url if (!empty($page_url)) { $this->metas['og-url']['content'] = $page_url; $this->metas['og-url']['type'] = 'property="og:url"'; } // image $og_image = qa_opt('useo_social_og_image'); if (!empty($og_image)) { $this->metas['og-image']['content'] = $og_image; $this->metas['og-image']['type'] = 'property="og:image"'; } } if (qa_opt('useo_social_tc_enable')) { // Twitter Cards // type $this->metas['tc-type']['content'] = 'summary'; $this->metas['tc-type']['type'] = 'property="twitter:card"'; // title $this->metas['tc-title']['content'] = $title; $this->metas['tc-title']['type'] = 'property="twitter:title"'; // description $useo_social_tc_desc_length = qa_opt('useo_social_og_desc_length'); if ($useo_social_tc_desc_length <= 0) { $useo_social_tc_desc_length = 120; } $this->metas['tc-description']['content'] = useo_get_excerpt($description, 0, $useo_social_tc_desc_length); $this->metas['tc-description']['type'] = 'property="twitter:description"'; // image $tc_image = qa_opt('useo_social_tc_image'); if (!empty($tc_image)) { $this->metas['tc-image']['content'] = $tc_image; $this->metas['tc-image']['type'] = 'property="twitter:image"'; } // handler // twitter handler goes into "site" field of meta tag $tc_handler = qa_opt('useo_social_tc_handler'); if (!empty($tc_handler)) { $this->metas['tc-handler']['content'] = $tc_handler; $this->metas['tc-handler']['type'] = 'property="twitter:site"'; } } if (qa_opt('useo_social_schema_enable')) { // Twitter Cards // title $this->metas['gp-title']['content'] = $title; $this->metas['gp-title']['type'] = 'itemprop="name"'; // description $this->metas['gp-title']['content'] = $description; $this->metas['gp-title']['type'] = 'itemprop="description"'; // type $gp_type = qa_opt('useo_social_schema_page_type'); if ($gp_type == 2) { $gp_page_type = 'Question'; } elseif ($gp_type == 3) { $gp_page_type = 'Article'; } if (isset($gp_page_type)) { $this->metas['gp-title']['content'] = ''; $this->metas['gp-title']['type'] = 'itemscope itemtype="http://schema.org/' . $gp_page_type . '"'; } // description $gp_image = qa_opt('useo_social_gp_thumbnail'); if (!empty($gp_image)) { $this->metas['gp-image']['content'] = $gp_image; $this->metas['gp-image']['type'] = 'itemprop="image"'; } } } // category link titles $useo_cat_desc_map = array(); $categoryid_list = array(); //prepare category navigation ids if (isset($this->content['navigation']['cat']) && qa_opt('useo_cat_title_nav_enable')) { $category_nav = $this->content['navigation']['cat']; unset($category_nav['all']); foreach ($category_nav as $index => $item) { $categoryid_list[$item['categoryid']] = $item['categoryid']; } } // prepare question list ids if (isset($this->content["q_list"]["qs"]) && qa_opt('useo_cat_title_qlist_enable')) { foreach ($this->content["q_list"]["qs"] as $index => $item) { if ($item['raw']['categoryid']) { $categoryid_list[$item['raw']['categoryid']] = $item['raw']['categoryid']; } } } // get all category titles if (count($categoryid_list)) { $result = qa_db_query_sub('SELECT categoryid, content FROM ^categorymetas WHERE categoryid IN ($) AND title=$', $categoryid_list, 'useo_cat_title'); $useo_cat_desc_map = qa_db_read_all_assoc($result, 'categoryid'); if (isset($this->content["q_list"]["qs"])) { foreach ($this->content["q_list"]["qs"] as $index => $item) { if (isset($item['raw']['categoryid']) && isset($useo_cat_desc_map[$item['raw']['categoryid']])) { $this->content["q_list"]["qs"][$index]['where']['title'] = $useo_cat_desc_map[$item['raw']['categoryid']]['content']; } } } } // set category title for navigation if (count(@$this->content['navigation']['cat']) && qa_opt('useo_cat_title_nav_enable')) { foreach ($this->content['navigation']['cat'] as $index => $item) { if (isset($item['categoryid']) && isset($useo_cat_desc_map[$item['categoryid']])) { $this->content['navigation']['cat'][$index]["popup"] = $useo_cat_desc_map[$item['categoryid']]['content']; } } } // Administrator panel navigation item if ($this->request == 'admin/ulitmate_seo') { if (empty($this->content['navigation']['sub'])) { $this->content['navigation']['sub'] = array(); } require_once QA_INCLUDE_DIR . 'qa-app-admin.php'; $admin_nav = qa_admin_sub_navigation(); $this->content['navigation']['sub'] = array_merge($admin_nav, $this->content['navigation']['sub']); } if ($this->template == 'admin' or $this->request == 'ulitmate_seo') { $this->content['navigation']['sub']['ulitmate_seo'] = array('label' => 'Ultimate SEO', 'url' => qa_path_html('admin/ulitmate_seo')); if ($this->request == 'admin/ulitmate_seo') { $this->content['navigation']['sub']['ulitmate_seo']['selected'] = true; } } }
function body_content() { $this->body_prefix(); $this->notices(); $this->widgets('full', 'top'); // Q2A header $this->widgets('full', 'high'); $this->header(); $this->output('<div class="container-fluid' . (qa_opt('it_nav_fixed') ? ' fixed-nav-container' : '') . '">'); // list of pages with no sidebar $pages = array("qa", "questions", "user", "user-wall", "user-activity", "Linux", "user-questions", "user-answers"); // pages without sidebar if (in_array($this->template, $pages)) { // Q2A default body $this->output('<section class="qa-main-content col-md-12">'); $this->main(); $this->output('</section>'); } else { $postid = @$this->content['q_view']['raw']['postid']; if (isset($postid)) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $image = qa_db_postmeta_get($postid, 'et_featured_image'); if (!empty($image) && substr(qa_get_state(), 0, 4) != 'edit') { $this->output('<img class="featured-image img-thumbnail" src="' . qa_opt('it_featured_url_abs') . 'featured/' . $image . '"/>'); } } // Q2A sidebar if ($this->request == 'admin/it_options' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { // Q2A default body $this->output('<section class="qa-main-content col-md-12">'); $this->main(); $this->output('</section>'); } else { $this->output('<aside class="qa-main-sidebar col-md-3">'); $this->sidepanel(); $this->output('</aside>'); // Q2A default body $this->output('<section class="qa-main-content col-md-9">'); $this->main(); $this->output('</section>'); } } $this->output('</div>'); // Q2A Footer $this->widgets('full', 'low'); $this->footer(); $this->widgets('full', 'bottom'); $this->body_suffix(); }
function doctype() { qa_html_theme_base::doctype(); if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { // theme installation & update $version = qa_opt('IT_VERSION'); if (IT_VERSION > $version) { qa_redirect('it_installation'); } // admin/category form fields if ($this->request == 'admin/categories' && qa_get('edit') >= 1) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $categoryid = qa_get('edit'); $et_category = json_decode(qa_db_categorymeta_get($categoryid, 'et_category'), true); $et_category_link_title = $et_category['et_cat_title']; $et_category_description = $et_category['et_cat_desc']; $et_category_icon_48 = $et_category['et_cat_icon48']; $et_category_icon_64 = $et_category['et_cat_icon64']; $this->content['form']['fields'][] = array('tags' => 'NAME="et_category_link_title" ID="et_category_link_title"', 'label' => 'Category Link Title', 'value' => $et_category_link_title); $this->content['form']['fields'][] = array('tags' => 'NAME="et_category_description" ID="et_category_description"', 'label' => 'Category Sidebar Description', 'value' => $et_category_description); $this->content['form']['fields'][] = array('tags' => 'NAME="et_category_icon_48" ID="et_category_icon_48"', 'label' => 'Category Icon(48 pixel)', 'value' => $et_category_icon_48); $this->content['form']['fields'][] = array('tags' => 'NAME="et_category_icon_64" ID="et_category_icon_64"', 'label' => 'Category Icon(64 pixel)', 'value' => $et_category_icon_64); } } // ask form if ($this->template == 'ask' or $this->template == 'question' && substr(qa_get_state(), 0, 4) == 'edit') { // Form template if ($this->template == 'ask') { $form_name = 'form'; } else { $form_name = 'form_q_edit'; } // Featured Image if (qa_opt('it_feature_img_enable')) { $featured_image = ''; $featured_image_url = ''; $featured_image_style = ''; $featured_file_container_style = ''; if ($this->template != 'ask') { $postid = $this->content["q_view"]["raw"]["postid"]; require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $featured_image = qa_db_postmeta_get($postid, 'et_featured_image'); if (isset($featured_image)) { $featured_image_url = qa_opt('it_featured_url_abs') . 'featured/' . $featured_image; $featured_image_style = 'display: inline-block;'; $featured_file_container_style = 'display:none;'; } } $custom_field[0]['category_featured_upload']['label'] = ''; $custom_field[0]['category_featured_upload']['html'] = ' <div style="' . $featured_image_style . '" class="image-preview-container" id="image-preview-container"> <img class="image-preview img-thumbnail" id="image-preview" src="' . $featured_image_url . '"> <button class="btn btn-danger remove-featured-image" id="remove-featured-image" type="button">X</button> </div> <div id="featured_file_container" style="' . $featured_file_container_style . '"><div id="featured_file_upload"></div></div> <input type="hidden" value="' . $featured_image . '" name="featured_image" id="featured_image"> '; $custom_field[0]['category_featured_upload']['type'] = 'custom'; $count = count($this->content[$form_name]["fields"]); $featured_pos = 0; $this->content[$form_name]["fields"] = array_merge(array_slice($this->content[$form_name]["fields"], 0, $featured_pos), $custom_field[0], array_slice($this->content[$form_name]["fields"], $featured_pos, $count)); //v($custom_field); } else { $custom_field = array(); } // Excerpt Field if (qa_opt('it_excerpt_field_enable')) { if ($this->template == 'ask') { $excerpt_pos = (int) qa_opt('it_excerpt_pos_ask'); $excerit_text = ''; } else { $postid = $this->content["q_view"]["raw"]["postid"]; require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $excerpt_pos = (int) qa_opt('it_excerpt_pos_edit'); $excerit_text = qa_db_postmeta_get($postid, 'et_excerpt_text'); } } // Category Field if (qa_opt('it_cat_advanced_enable')) { if ($this->template == 'ask') { $category_pos = (int) qa_opt('it_cat_pos_ask'); //$field_value = qa_post_text('q_category'); } else { $category_pos = (int) qa_opt('it_cat_pos_edit'); } if (empty($this->content["q_view"]["raw"]["categoryid"])) { $this->content[$form_name]['fields']['category']['value'] = ''; } $this->content[$form_name]['fields']['category']['type'] = 'text'; $this->content[$form_name]['fields']['category']['label'] = ''; $this->content[$form_name]['fields']['category']['tags'] = 'name="q_category" id="category_tag" autocomplete="off" onkeyup="qa_cat_tag_hints();" onmouseup="qa_cat_tag_hints();"'; $this->content[$form_name]['fields']['category']['note_force'] = true; $custom_field[1]['category_tag_holder']['label'] = 'This tip is about:'; $custom_field[1]['category_tag_holder']['html'] = '<div id="category_tag_holder"></div>'; $custom_field[1]['category_tag_holder']['type'] = 'custom'; } else { $custom_field[1] = array(); $category_pos = 0; } // order of form elements $count = count($this->content[$form_name]["fields"]); $this->content[$form_name]["fields"] = array_merge(array_slice($this->content[$form_name]["fields"], 0, $category_pos), $custom_field[1], array_slice($this->content[$form_name]["fields"], $category_pos, $count)); // Excerpt Custom Fields if (qa_opt('it_excerpt_field_enable')) { $custom_field = array(); $custom_field[0]['excerpt']['label'] = 'Add Excerpt'; $custom_field[0]['excerpt']['html'] = ' <textarea name="q-excerpt" id="excerpt-input-placeholder" class="qa-form-tall-text" cols="40" rows="3" name="excerpt-input-placeholder" placeholder="If you add an excerpt it will be used in lists">' . $excerit_text . '</textarea> '; $custom_field[0]['excerpt']['type'] = 'custom'; $count = count($this->content[$form_name]["fields"]); $this->content[$form_name]["fields"] = array_merge(array_slice($this->content[$form_name]["fields"], 0, $excerpt_pos), $custom_field[0], array_slice($this->content[$form_name]["fields"], $excerpt_pos, $count)); } } }
function cs_ajax_delete_featured_image() { $args = strip_tags($_REQUEST['args']); $args = explode('_', $args); print_r($args); if (qa_get_logged_in_level() > QA_USER_LEVEL_ADMIN && isset($args) && qa_check_form_security_code('delete-image', $args[0])) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $img = qa_db_postmeta_get($args[1], 'featured_image'); if (!empty($img)) { $thumb_img = preg_replace('/(\\.[^.]+)$/', sprintf('%s$1', '_s'), $img); $thumb = Q_THEME_DIR . '/uploads/' . $thumb_img; $big_img = Q_THEME_DIR . '/uploads/' . $img; qa_db_postmeta_clear($args[1], 'featured_image'); if (file_exists($big_img)) { unlink($big_img); } if (file_exists($thumb)) { unlink($thumb); } } } die; }