<?php $model = $_REQUEST['model']; $action = $_REQUEST['action']; include_once MODELS_ADMIN . "/" . $model . "_model.php"; switch (strtoupper($action)) { case 'ADD': break; case 'SAVE': if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Save') { $objBlogType = new BlogType(); $objBlogType->setBlogType($_REQUEST); $objComm->redirect('index.php?model=' . $model); } break; case 'VIEW': case 'EDIT': if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Update') { $objBlogType = new BlogType(); $objBlogType->setBlogType($_REQUEST); $objComm->redirect('index.php?model=' . $model . '&action=edit&id=' . $_REQUEST['pk_id']); } else { $objBlogType = new BlogType(); $datum = $objBlogType->getBlogType($_REQUEST['id'], $action); } break; default: $objBlogType = new BlogType(); $data = $objBlogType->getAllBlogType(); break; }
/** * Processes list constraints passed in an array. * * @param array $p_constraints * @return array */ protected function ProcessConstraints(array $p_constraints) { $parameters = array(); $state = 1; $attribute = null; $operator = null; $value = null; foreach ($p_constraints as $index=>$word) { switch ($state) { case 1: // reading the parameter name $attribute = strtolower($word); if (!array_key_exists($attribute, self::$s_parameters)) { CampTemplate::singleton()->trigger_error("invalid attribute $word in statement list_blogentries, constraints parameter"); return false; } if ($attribute == 'keyword') { $operator = new Operator('is', 'string'); $state = 3; } elseif ($attribute == 'matchalltopics' || $attribute == 'matchanytopic') { if ($attribute == 'matchalltopics') { $operator = new Operator('is', 'boolean'); $comparisonOperation = new ComparisonOperation($attribute, $operator, 'true'); $parameters[] = $comparisonOperation; } $state = 1; } else { $state = 2; } if ($attribute == 'onfrontpage' || $attribute == 'onsection') { if (($index + 1) < count($p_constraints)) { try { $operator = new Operator($p_constraints[$index+1], 'switch'); } catch (InvalidOperatorException $e) { $operator = new Operator('is', 'switch'); $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on'); $parameters[] = $comparisonOperation; $state = 1; } } else { $operator = new Operator('is', 'switch'); $comparisonOperation = new ComparisonOperation($attribute, $operator, 'on'); $parameters[] = $comparisonOperation; $state = 1; } } break; case 2: // reading the operator $type = self::$s_parameters[$attribute]['type']; try { $operator = new Operator($word, $type); } catch (InvalidOperatorException $e) { CampTemplate::singleton()->trigger_error("invalid operator $word of parameter constraints.$attribute in statement list_blogentries"); return false; } $state = 3; break; case 3: // reading the value to compare against $type = self::$s_parameters[$attribute]['type']; $metaClassName = 'Meta'.ucfirst($type); try { $valueObj = new $metaClassName($word); } catch (InvalidValueException $e) { CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries"); return false; } if ($attribute == 'type') { $word = trim($word); $blogType = new BlogType($word); if (!$blogType->exists()) { CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries"); return false; } $value = $word; } elseif ($attribute == 'topic') { $topicObj = new Topic($word); if (!$topicObj->exists()) { CampTemplate::singleton()->trigger_error("invalid value $word of parameter constraints.$attribute in statement list_blogentries"); return false; } else { $value = $topicObj->getTopicId(); } } elseif ($attribute == 'author') { if (strtolower($word) == '__current') { $context = CampTemplate::singleton()->context(); $value = $context->blog->author->name; } else { $value = $word; } } else { $value = $word; } $comparisonOperation = new ComparisonOperation($attribute, $operator, $value); $parameters[] = $comparisonOperation; $state = 1; break; } } if ($state != 1) { CampTemplate::singleton()->trigger_error("unexpected end of constraints parameter in list_blogentries"); return false; } return $parameters; }