コード例 #1
0
/**
 * Prints the dropdown menu for the category selector for the news articles list
 *
 */
function printCategoryDropdown()
{
    global $_zp_zenpage;
    $currentpage = $_zp_zenpage->getCurrentAdminNewsPage();
    $result = $_zp_zenpage->getAllCategories(false);
    if (isset($_GET['date'])) {
        $datelink = "&date=" . $_GET['date'];
        $datelinkall = "?date=" . $_GET['date'];
    } else {
        $datelink = "";
        $datelinkall = "";
    }
    if (isset($_GET['category'])) {
        $selected = '';
        $category = sanitize($_GET['category']);
    } else {
        $selected = "selected='selected'";
        $category = "";
    }
    ?>
	<form name ="AutoListBox2" id="categorydropdown" style="float:left" action="#" >
	<select name="ListBoxURL" size="1" onchange="gotoLink(this.form)">
		<?php 
    echo "<option {$selected} value='admin-news-articles.php?pagenr=" . $currentpage . getNewsAdminOptionPath(false, true, true) . "'>" . gettext("All categories") . "</option>\n";
    foreach ($result as $cat) {
        $catobj = new ZenpageCategory($cat['titlelink']);
        // check if there are articles in this category. If not don't list the category.
        $count = count($catobj->getArticles(0, 'all'));
        $count = " (" . $count . ")";
        if ($category == $cat['titlelink']) {
            $selected = "selected='selected'";
        } else {
            $selected = "";
        }
        //This is much easier than hacking the nested list function to work with this
        $getparents = $catobj->getParents();
        $levelmark = '';
        foreach ($getparents as $parent) {
            $levelmark .= '&raquo; ';
        }
        $title = $catobj->getTitle();
        if (empty($title)) {
            $title = '*' . $catobj->getTitlelink() . '*';
        }
        if ($count != " (0)") {
            echo "<option {$selected} value='admin-news-articles.php?pagenr=" . $currentpage . "&amp;category=" . $catobj->getTitlelink() . getNewsAdminOptionPath(false, true, true) . "'>" . $levelmark . $title . $count . "</option>\n";
        }
    }
    ?>
	</select>
	<script language="JavaScript" type="text/javascript" >
		// <!-- <![CDATA[
		function gotoLink(form) {
		var OptionIndex=form.ListBoxURL.selectedIndex;
		parent.location = form.ListBoxURL.options[OptionIndex].value;}
		// ]]> -->
</script>
</form>
<?php 
}
コード例 #2
0
 /**
  * Gets the parent categories recursivly to the category whose parentid is passed or the current object
  *
  * @param int $parentid The parentid of the category to get the parents of
  * @param bool $initparents
  * @return array
  */
 function getParents(&$parentid = '', $initparents = true)
 {
     global $parentcats, $_zp_zenpage;
     $allitems = $_zp_zenpage->getAllCategories(false);
     if ($initparents) {
         $parentcats = array();
     }
     if (empty($parentid)) {
         $currentparentid = $this->getParentID();
     } else {
         $currentparentid = $parentid;
     }
     foreach ($allitems as $item) {
         $obj = new ZenpageCategory($item['titlelink']);
         $itemtitlelink = $obj->getTitlelink();
         $itemid = $obj->getID();
         $itemparentid = $obj->getParentID();
         if ($itemid == $currentparentid) {
             array_unshift($parentcats, $itemtitlelink);
             $obj->getParents($itemparentid, false);
         }
     }
     return $parentcats;
 }
コード例 #3
0
/**
* Prints all available articles or categories in Zenpage
*
* @param string $current

 set to category selected (if any)
*
* @return string
*/
function printZenpageNewsCategorySelector($current)
{
    global $_zp_gallery, $_zp_zenpage;
    ?>
	<select id="categoryselector" name="categoryselect">
		<?php 
    $cats = $_zp_zenpage->getAllCategories(false);
    foreach ($cats as $cat) {
        if ($cat['titlelink'] == $current) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        $catobj = new ZenpageCategory($cat['titlelink']);
        //This is much easier than hacking the nested list function to work with this
        $getparents = $catobj->getParents();
        $levelmark = '';
        foreach ($getparents as $parent) {
            $levelmark .= '» ';
        }
        echo "<option value = '" . html_encode($catobj->getTitlelink()) . "'" . $selected . '>';
        echo $levelmark . $catobj->getTitle() . "</option>";
    }
    ?>
	</select>
	<?php 
}
コード例 #4
0
 /**
  * Checks if an article is in a sub category of $catlink
  *
  * @param string $catlink The titlelink of a category
  * @return bool
  */
 function inSubNewsCategoryOf($catlink)
 {
     if (!empty($catlink)) {
         $categories = $this->getCategories();
         $count = 0;
         foreach ($categories as $cat) {
             $catobj = new ZenpageCategory($cat['titlelink']);
             $parentid = $catobj->getParentID();
             $parentcats = $catobj->getParents();
             foreach ($parentcats as $parentcat) {
                 if ($catlink == $parentcat) {
                     $count = 1;
                     break;
                 }
             }
         }
         return $count == 1;
     } else {
         return false;
     }
 }