コード例 #1
0
ファイル: admin-import.php プロジェクト: ricasiano/mca-site
    ?>
		</p>
	<?php 
} else {
    ?>
		<ul id="catablog-import-messages">
			<?php 
    if (isset($_REQUEST['catablog_clear_db'])) {
        ?>
				
				<li class="updated"><em><?php 
        _e("removing catalog items...", 'catablog');
        ?>
</em></li>
				<?php 
        $items = CataBlogItem::getItems();
        ?>
				<?php 
        foreach ($items as $item) {
            ?>
					<?php 
            $item->delete(false);
            ?>
				<?php 
        }
        ?>
				<li class="updated"><?php 
        _e("Success: <em>All</em> catalog items removed successfully", 'catablog');
        ?>
</li>
				
コード例 #2
0
ファイル: CataBlog.class.php プロジェクト: ricasiano/mca-site
 public function frontend_shortcode_catablog($atts)
 {
     $shortcode_params = array('category' => false, 'template' => false, 'sort' => 'menu_order', 'order' => 'asc', 'operator' => 'IN', 'limit' => -1, 'navigation' => true);
     extract(shortcode_atts($shortcode_params, $atts));
     // if sort equals order, change it to menu_order
     $sort = $sort == 'order' ? 'menu_order' : $sort;
     // modify the operator if it is a possibly wrong format to work with WP.
     $operator = str_replace("-", " ", strtoupper($operator));
     // disable navigation if it is present in the turn off words array
     $turn_off_nav_words = array(false, 'no', 'off', 'disable', 'disabled', 'false');
     $navigation = in_array(strtolower($navigation), $turn_off_nav_words) ? false : true;
     // initialize pagination variables
     $paged = 1;
     $total = 0;
     if (isset($_REQUEST[$this->pagination_query_label])) {
         $paged = is_numeric($_REQUEST[$this->pagination_query_label]) ? intval($_REQUEST[$this->pagination_query_label]) : 1;
     }
     $offset = ($paged - 1) * $limit;
     // get items from cache and start the output buffer
     if (isset($this->results_cache)) {
         $results = $this->results_cache;
     } else {
         // extract all category ids
         if (!empty($category)) {
             // separate categories and trim names
             $categories = explode(',', $category);
             array_walk($categories, create_function('&$val', '$val = trim($val);'));
             // load all category names and ids in the catalog
             $catalog_terms = array();
             foreach ($this->get_terms() as $term) {
                 $lowercase_name = strtolower($term->name);
                 $catalog_terms[$lowercase_name] = $term->term_id;
             }
             // loop over shortcode categories, matching names and setting ids if available
             $category_ids = array();
             foreach ($categories as $category) {
                 $id = -1;
                 $lowercase_name = strtolower($category);
                 if (in_array($lowercase_name, array_keys($catalog_terms))) {
                     $id = $catalog_terms[$lowercase_name];
                 }
                 $category_ids[] = $id;
             }
             // remove any duplicate category ids and set the ids array to $category
             $category_ids = array_unique($category_ids);
             $category = $category_ids;
         }
         // !! NOTE: Eventually $offset and $limit should be used here for better db performance
         $results = CataBlogItem::getItems($category, $operator, $sort, $order);
         $total = count($results);
         if ($limit > 0) {
             $results = array_slice($results, $offset, $limit, true);
         }
     }
     ob_start();
     if ($navigation) {
         if ($this->options['nav-location'] != 'bottom') {
             $this->frontend_build_navigation($paged, $limit, $total);
         }
     }
     echo "<div class='catablog-catalog'>";
     foreach ($results as $result) {
         // render all items if the category is not set
         // if ($category === false) {
         echo $this->frontend_render_catalog_row($result, $template);
         // }
         // render only the items in the set category
         // else if ($result->inCategory($category)) {
         // echo $this->frontend_render_catalog_row($result, $template);
         // }
     }
     echo "</div>";
     if ($navigation) {
         if ($this->options['nav-location'] != 'top') {
             $this->frontend_build_navigation($paged, $limit, $total);
         }
     }
     return ob_get_clean();
 }