protected function _viewPlace($placeCode = null, $options = array())
 {
     $prependHtml = isset($options['prepend']) ? $options['prepend'] : '';
     $appendHtml = isset($options['append']) ? $options['append'] : '';
     if ($placeCode === null) {
         return;
     }
     $controllerName = zenMVC::getFinalControllerName();
     $controllersBreadcrumb = zenMVC::getControllersBreadcrumb();
     $filters = zenMVC::getPlaceFilters();
     $widgets = $this->_getPlaceWidgets($placeCode, $options);
     $widgetsPlacement = $this->getTable('widgets_placement');
     $conditions = $this->getTable('widgets_placement_conditions');
     // get widgets for place
     echo $prependHtml;
     echo '<div style="border: solid 1px #e00;">';
     $parents = $this->getClassParents($controllerName);
     $in = $parents;
     $in[] = $controllerName;
     $in[] = '';
     $widgetList = $widgetsPlacement->select()->where("{$widgetsPlacement->place_code} = '" . $widgetsPlacement->e($placeCode) . "'")->where("{$widgetsPlacement->controller_class} IN('" . implode("','", $in) . "')");
     $filters = zenMVC::getPlaceFilters();
     if (count($filters)) {
         $widgetList = $widgetList->select($conditions);
         //$sqla = array();
         // where ... or ... or ... having count(id) = filters_count
         foreach ($filters as $name => $value) {
             $widgetList = $widgetList->where("{$conditions->name} = '" . $conditions->e($name) . "'")->where("{$conditions->value} = '" . $conditions->e($value) . "'");
         }
     } else {
         $widgetList = $widgetList->leftJoin($conditions)->select($conditions)->where("{$conditions->id} IS NULL");
     }
     foreach ($widgetList as $result) {
         list($placement, $conditions) = $result;
         $class = $placement->widgetClass->getValue();
         $widget = new $class($this);
         echo $placement->id->html();
         $widget->setPlacement($placement);
         $widget->html();
     }
     echo $widgetList->getSql();
     echo '<div>' . $placeCode . '</div>';
     echo '<div>' . $controllerName . '</div>';
     echo '<div>';
     var_dump($controllersBreadcrumb);
     echo '</div>';
     echo '<div>';
     var_dump($filters);
     echo '</div>';
     echo '<div>';
     //var_dump($options);
     echo '</div>';
     echo '</div>';
     echo $appendHtml;
 }
Example #2
0
 protected function _viewPlace($placeCode = null, $options = array())
 {
     $prependHtml = isset($options['prepend']) ? $options['prepend'] : '';
     $appendHtml = isset($options['append']) ? $options['append'] : '';
     if ($placeCode === null) {
         return;
     }
     $controllerName = zenMVC::getFinalControllerName();
     $controllersBreadcrumb = zenMVC::getControllersBreadcrumb();
     $filters = zenMVC::getPlaceFilters();
     $widgets = $this->_getPlaceWidgets($placeCode, $options);
     $widgetsPlacement = $this->getTable('widgets_placement');
     $conditions = $this->getTable('widgets_placement_conditions');
     // get widgets for place
     $parents = $this->getClassParents($controllerName);
     $parents = $controllersBreadcrumb;
     //$in = array();
     //$in[] = $controllerName;
     $in = $parents;
     $in[] = '';
     //$in[] = $controllerName;
     $widgetList = $widgetsPlacement->select()->where("{$widgetsPlacement->place_code} = '" . $widgetsPlacement->e($placeCode) . "'")->orderBy("{$widgetsPlacement->order} ASC");
     $filters = zenMVC::getPlaceFilters();
     if (count($filters)) {
         //$widgetList = $widgetList->leftJoin($conditions)->select($conditions);
         //$sqla = array();
         // where ... or ... or ... having count(id) = filters_count
         //$controllerName
         foreach ($filters as $name => $value) {
             $filter = $name . '=' . $value;
             /*							$conditions->name = '".$conditions->e($name)."' 
             						AND $conditions->value = '".$conditions->e($value)."'
             */
             $widgetList = $widgetList->where("\n\t\t\t\t\t((\n\t\t\t\t\t\t{$widgetsPlacement->filter} = '{$filter}'\n\t\t\t\t\t\tAND {$widgetsPlacement->controller_class} = '{$controllerName}'\n\t\t\t\t\t)OR(\n\t\t\t\t\t\t{$widgetsPlacement->child_controllers} = 1\n\t\t\t\t\t\tAND\t{$widgetsPlacement->controller_class} IN('" . implode("', '", $in) . "')\n\t\t\t\t\t))");
         }
     } else {
         //$widgetList = $widgetList->leftJoin($conditions)->select($conditions)
         //->where("$widgetsPlacement->controller_class IN('".implode("','", $in)."')")
         $widgetList = $widgetList->where("\n\t\t\t\t\t((\n\t\t\t\t\t\t{$widgetsPlacement->filter} = ''\n\t\t\t\t\t\tAND {$widgetsPlacement->controller_class} = '{$controllerName}'\n\t\t\t\t\t)OR(\n\t\t\t\t\t\t{$widgetsPlacement->filter} = ''\n\t\t\t\t\t\tAND {$widgetsPlacement->child_controllers} = 1\n\t\t\t\t\t\tAND\t{$widgetsPlacement->controller_class} IN('" . implode("', '", $in) . "')\n\t\t\t\t\t))\n\t\t\t\t\t");
     }
     if (count($widgetList)) {
         echo $prependHtml;
         echo '<div class="place place-' . $placeCode . '">';
         // style="border: solid 1px #e00; overflow: hidden;"
         foreach ($widgetList as $placement) {
             //list($placement, $conditions) = $result;
             $class = $placement->widgetClass->getValue();
             $widget = new $class($this);
             //echo $placement->id->html();
             $widget->setPlacement($placement);
             $widget->html();
         }
         echo '</div>';
         echo $appendHtml;
     }
 }
Example #3
0
 public function run()
 {
     $this->onConstruct();
     $class = get_class($this);
     zenMVC::setFinalControllerName($class);
     //var_dump($this->_relativeUri->getBasePath());
     if ($action = $this->_relativeUri->getBasePath()) {
         $this->_action = $action;
         $uc = ucfirst($action);
         $actionFunction = 'action' . $uc;
         $initFunction = 'init' . $uc;
         $showFunction = 'show' . $uc;
         // prepare uri
         $childUri = clone $this->_baseUri;
         $path = $childUri->getPath();
         $path[] = $action;
         $childUri->setPath($path);
         $this->_childUri = strval($childUri);
         $methodFound = false;
         if (method_exists($this, $initFunction)) {
             $methodFound = true;
             $method = $this->_me->getMethod($initFunction);
             $parameters = $method->getParameters();
             $args = array();
             foreach ($parameters as $p) {
                 $name = $p->getName();
                 //$defaultValue = $p->isDefaultValueAvailable()?$p->getDefaultValue():null;
                 if (isset($_GET[$name])) {
                     $value = $_GET[$name];
                 } elseif (isset($_POST[$name])) {
                     $value = $_POST[$name];
                 } else {
                     $value = $p->isDefaultValueAvailable() ? $p->getDefaultValue() : null;
                 }
                 $args[] = $value;
                 //$name
             }
             call_user_func_array(array($this, $initFunction), $args);
         }
         if (method_exists($this, $actionFunction)) {
             $methodFound = true;
             call_user_func(array($this, $actionFunction));
         }
         if (method_exists($this, $showFunction)) {
             $methodFound = true;
             $method = $this->_me->getMethod($showFunction);
             $parameters = $method->getParameters();
             $args = array();
             foreach ($parameters as $p) {
                 $name = $p->getName();
                 //$defaultValue = $p->isDefaultValueAvailable()?$p->getDefaultValue():null;
                 if (isset($_GET[$name])) {
                     $value = $_GET[$name];
                 } elseif (isset($_POST[$name])) {
                     $value = $_POST[$name];
                 } else {
                     $value = $p->isDefaultValueAvailable() ? $p->getDefaultValue() : null;
                 }
                 $args[] = $value;
                 //$name
             }
             $this->_header();
             call_user_func_array(array($this, $showFunction), $args);
             $this->_footer();
         }
         if (!$methodFound) {
             //var_dump($this);
             return $this->_action($action);
         }
     } else {
         //echo 'hERE'.get_class($this);
         if (method_exists($this, 'customIndex')) {
             $this->customIndex();
         } else {
             //echo 'hERE'.get_class($this);
             $this->_initIndex();
             $this->_header();
             $this->index();
             $this->_footer();
         }
     }
 }