Example #1
0
 public function categories($return_js = TRUE)
 {
     Config::getConection();
     $DAO = new CategoryDAO();
     $result = $DAO->selectCascade(CategoryDAO::RETURN_STD_OBJECT, 2, 1);
     //prepara
     if ($result->success) {
         $this->prepareCategories($result->result);
     }
     if ($return_js) {
         echo "var array_categories = " . json_encode($result->result) . ";";
         exit;
     }
     return $result;
 }
Example #2
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new CategoryDAO();
     }
     return self::$instance;
 }
 public function getHierarchy()
 {
     if ($s = CategoryDAO::getByChildIngredient($this)) {
         return $s[0]->getLabel() . ' > ';
     }
     return '';
 }
Example #4
0
function displaysearch()
{
    $language_fields_addition = $_SESSION['language'] == 'en_US' ? '' : '_' . $_SESSION['language'];
    //select all the categories in the database
    $category_dao = new CategoryDAO();
    $categories = $category_dao->getAllCategories();
    $specification_dao = new SpecificationDAO();
    ?>

<ul class="nav nav-tabs">
	<?php 
    foreach ($categories as $category) {
        ?>
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php 
        echo $category->{'name' . $language_fields_addition};
        ?>
    		<span class="caret"></span></a>
     <?php 
        $specifications = $specification_dao->getbyCategoryid($category->id);
        ?>
     	<ul class="dropdown-menu">
     	<?php 
        foreach ($specifications as $specification) {
            ?>
        		<li><a href="?category=<?php 
            echo $category->id;
            ?>
&specification=<?php 
            echo $specification->id;
            ?>
"><?php 
            echo $specification->{'name' . $language_fields_addition};
            ?>
</a></li>
       	<?php 
        }
        ?>
        </ul>
      <?php 
    }
    ?>
</ul>

<?php 
}
Example #5
0
 public function __construct($arrayRestFolder)
 {
     Config::getConection();
     $this->DAO = CategoryDAO::getInstance();
     if ($arrayRestFolder != NULL) {
         $this->arrayRestFolder = $arrayRestFolder;
         $this->arrayVariable = Navigation::getVariableArraySlug($this->arrayRestFolder);
         //$this->MenuController = new MenuController($this->arrayVariable);
     }
 }
Example #6
0
 public function getFooter()
 {
     //iniciando o retorno padrao $ReturnResultVO
     $ReturnResultVO = new ReturnResultVO();
     //inicia a DAO
     $DAO = CategoryDAO::getInstance();
     $selectCategory = "footer";
     //pesquisa pela categoria pai
     $ReturnDataVO = $DAO->select(CategoryDAO::RETURN_VO, NULL, NULL, NULL, NULL, $selectCategory);
     if ($ReturnDataVO->success && count($ReturnDataVO->result) > 0) {
         //pega a CategoriaVO pai da resposta
         $DadCategoryVO = $ReturnDataVO->result[0];
         //traduz os compos da categoria pai conforme o locale
         $StdClassDadCategory = $DadCategoryVO->toStdClass(Config::getLocale());
         //inicia um array para armazenar os contents da categoria pai
         $arrayStdClassHighlights = array();
         //adiciona os conents encontrados no campo $array_highlights da categoria pai $StdClassDadCategory
         $StdClassDadCategory->array_highlights = $arrayStdClassHighlights;
         $arrayChildsCategoryVO = array();
         //busca as categorias Filhas da pai
         $ReturnDataVO = $DAO->select(CategoryDAO::RETURN_VO, NULL, NULL, $StdClassDadCategory->id, NULL, NULL, "<");
         if ($ReturnDataVO->success) {
             $arrayChildsCategoryVO = $ReturnDataVO->result;
             $StdClassArrayChildsCategoryVO = array();
             foreach ($arrayChildsCategoryVO as $ChildsCategoryVO) {
                 //traduz os compos da categoria filha conforme o locale
                 $StdClassChildCategory = $ChildsCategoryVO->toStdClass(Config::getLocale());
                 //inicia a GenericHighLghtDAO para fazer a consulta
                 $DAO = GenericHighLightsDAO::getInstance();
                 //busca highlightss vinculados a tabela e tabela id passados
                 $ReturnDataVO = $DAO->selectByTableId("category", $StdClassChildCategory->id, GenericHighLightsDAO::RETURN_VO, "highlights");
                 //Debug::print_r($ReturnDataVO);exit();
                 //Debug::print_r($ReturnResultVO);
                 //inicia um array para armazenar os contents da categoria filho
                 $arrayStdClassHighlights = array();
                 //pega as imagens vinculadas ao content e tabem traduz os campos do mesmo content da categoria filho conforme o locale solicitado
                 foreach ($ReturnDataVO->result as $HighLightsVO) {
                     $arrayStdClassHighlights[] = $HighLightsVO->toStdClass(Config::getLocale());
                 }
                 //adiciona os conents encontrados no campo $array_highlights da categoria pai $StdClassDadCategory
                 $StdClassChildCategory->array_highlights = $arrayStdClassHighlights;
                 //adiciona o a categoria filho no array de categorias filho
                 $StdClassArrayChildsCategoryVO[] = $StdClassChildCategory;
             }
             //setando sucesso true caso tenha dado certo
             $ReturnResultVO->success = TRUE;
             $ReturnResultVO->result = $StdClassArrayChildsCategoryVO;
         }
     }
     //Debug::print_r($ReturnResultVO);
     return $ReturnResultVO;
 }
Example #7
0
 public function init()
 {
     //se for postado algo ta tentando atualizar... atualiza em silencio
     if ($_POST) {
         include_once "library/site/modules/content/dao/ContentDemoDAO.class.php";
         include_once "library/facil3/core/modules/category/dao/CategoryDAO.class.php";
         include_once "library/site/modules/banner/vo/BannerConfigVO.class.php";
         $ContentDemoDAO = ContentSiteDAO::getInstance();
         $CategoryDAO = CategoryDAO::getInstance();
         $CategoryVO = new BannerConfigVO();
         $CategoryVO->setId(47, TRUE);
         /*
         * Array(
          [transitionType] => 1
          [transitionDelayTimeFixed] => 2
          )
         */
         //exit();
         $CategoryVO->commit();
         //exit();
     }
     $returnResult = parent::init();
     $novo_content = array();
     foreach ($this->arrayContentsVO as $ContentsVO) {
         if ($ContentsVO->active < 2) {
             $novo_content[] = $ContentsVO;
         }
     }
     $this->arrayContentsVO = $novo_content;
     //$ContentVO->toStdClass(Config::getLocale());
     $SelectData = new ContentSelectView($this->arrayContentsVO);
     $SelectData->setGoToLocation(array("value" => "admin/home/"));
     $SelectData->gerate();
     $SelectData->hat["label"] = "Url:";
     $SelectData->setMassiveAttr('visible', FALSE, array('Name', 'Description', 'Content', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order'));
     $SelectData = $SelectData->getFormData();
     $HttpContentResult = $returnResult->getHttpContentResult();
     $HttpContentResult->selectData = $SelectData;
     $HttpContentResult->category_id = $this->category_id;
     $returnResult->setHttpContentResult($HttpContentResult);
     $HttpResult = $returnResult;
     //para o botao de inserir
     $HttpContentResult->url_insert = Config::getRootPath("admin/home/insert/");
     //include (Config::getFolderView( 'admin/home/index.php' )) ;
     //exit() ;
     //print_r($returnResult);exit();
     return $returnResult;
 }
Example #8
0
 public function delete()
 {
     $DAO = CategoryDAO::getInstance();
     if (FALSE) {
         $DAO = new CategoryDAO();
     }
     $DAO->delete(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     Navigation::redirect("admin/category/select");
 }
Example #9
0
 public function __construct()
 {
     parent::__construct();
 }
Example #10
0
 /**
  * Retorna a lista de categoria baseado na categoria pai. Não aceita nulo, se mandar nulo, nao funciona.
  * @param int $category_dad_id
  */
 private function getCategorysByCategoryDad($category_dad_id)
 {
     $DAO = CategoryDAO::getInstance();
     if (FALSE) {
         $DAO = new CategoryDAO();
     }
     $listReturnDataVO = $DAO->select(CategoryDAO::RETURN_VO, NULL, 1, $category_dad_id);
     return $listReturnDataVO;
 }
Example #11
0
<!-- This function display the specifications according to the category choose -->
function displayspecification(category_id) {

	var xhttp = new XMLHttpRequest();
	  xhttp.onreadystatechange = function() {
	    if (xhttp.readyState == 4 && xhttp.status == 200) {
	      document.getElementById("specification").innerHTML = xhttp.responseText;
	    }
	  }

	  xhttp.open("GET", "../getspecification.php?idcategory="+category_id, true);
	  xhttp.send();
}
</script>
<?php 
$category_dao = new CategoryDAO();
$categories = $category_dao->getAllCategories();
$page['title'] = 'Add product';
require '../../include/header.inc';
require '../../include/index.inc';
?>
<h3><?php 
echo t('Add product');
?>
</h3>
<form class="form-horizontal" action = "?" method="POST" enctype="multipart/form-data">

	 <div class="form-group">
	 	<label class="col-md-1 control-label" for="textinput"><?php 
echo t('Category');
?>
Example #12
0
 public function parseCategories()
 {
     $categories = new Categories();
     $keyParams = array();
     foreach ($this->xmlCategories as $xmlCategory) {
         $code = $xmlCategory->getCode();
         $name = $xmlCategory->getName();
         $isAGroup = $xmlCategory->isAGroup();
         if (!empty($code) && !in_array($code, $keyParams)) {
             array_push($keyParams, $code);
             $category = new Category();
             $category->setIsAGroup($isAGroup);
             $category->setCode($code);
             $category->setName($name);
             $categories->setItem($category);
         }
     }
     foreach ($this->xmlCategories as $xmlCategory) {
         $catCode = $xmlCategory->getCategoryCode();
         $code = $xmlCategory->getCode();
         $current = $categories->getItemByCode($code);
         $parent = $categories->getItemByCode($catCode);
         if ($parent != null) {
             $current->setParent($parent);
         }
     }
     $categoryDAO = new CategoryDAO();
     $categoryDAO->insertItems($categories);
     return $categories;
 }
Example #13
0
 /**
  * @param $typeOfReturn
  * @param $active
  * @return array_category
  * @desc atenção pedido retorno em std_class os dados não voltaram traduzidos pelo locale 
  */
 public function selectCascade($typeOfReturn = CategoryDAO::RETURN_STD_OBJECT, $active = NULL)
 {
     $this->DAO = CategoryDAO::getInstance();
     if ($this->array_category == NULL || $force) {
         //busca categorias filhas dessa
         $array_category = $this->DAO->selectCascade($typeOfReturn, $this->id, $active);
         if ($array_category->success) {
             //print_r($array_product->result);
             foreach ($array_category->result as $array_category_std) {
                 $this->array_category[] = $array_category_std;
             }
         }
     }
     return $this->array_category;
 }
Example #14
0
 /**
  * @desc o campo option do primeiro parametro ter os campos name e id
  * @param $args ("option"=>array("name"=>"nome", "id"=>"1"))
  * @param $array_selected_category
  * @return void
  */
 public function setPersonalInput($args = array())
 {
     $CategoryDAO = CategoryDAO::getInstance();
     $tempCategories = $CategoryDAO->select(CategoryDAO::RETURN_VO, NULL, 1);
     $link_categoryVO = $this->contentVO->getWhoILinked("category", 1);
     $array_selected_category = array();
     foreach ($link_categoryVO as $linkVO) {
         // $categoryVO = $linkVO->getLinkedVO();
         // var_dump($categoryVO);die;
         $array_selected_category[] = $linkVO->getTableId();
         //;
     }
     $Options = array();
     if (DataHandler::getValueByArrayIndex($args, "options")) {
         //converte para objeto
         $tempOption = DataHandler::getValueByArrayIndex($args, "options");
         $Options[] = (object) $tempOption;
     }
     $defs = array('label' => "", 'name' => 'personal', 'visible' => true, 'required' => false, 'selected' => $array_selected_category, 'type' => 'multiCheckbox', 'options' => $Options);
     $data = array_merge($defs, $args);
     //Debug::print_r($data);
     $this->personal_input = $data;
 }
Example #15
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);
header('Content-type: text/html; charset=utf-8');
require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/DAO/CategoryDAO.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/DAO/ActivityDAO.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/DAO/ImageDAO.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/model/Activity.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/model/Image.php';
$cat = new CategoryDAO();
$act = new ActivityDAO();
$imgDAO = new ImageDAO();
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/upload.php';
foreach ($cat->getCategoryList() as $category) {
    $catso[] = array($category->id => $category->name);
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/libs.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/Admin/view/menu/index.php';
$smarty->display("menu/menu.tpl");
require_once $_SERVER['DOCUMENT_ROOT'] . '/Admin/view/menu/activities.php';
$smarty->display("menu/activities.tpl");
$activities = $act->loadActivity(0, 0);
if (isset($_GET['mod'])) {
    switch ($_GET['mod']) {
        case 'list':
            $smarty->assign('activities', $activities);
            $smarty->display("activities/list.tpl");
            break;
        case 'new':
            $smarty->assign('cats', $catso);
<?php

$presenter->data['categories'] = CategoryDAO::getAll();
$presenter->data['recipes'] = RecipeDAO::getAll();