public function parse(&$f_pszViewType = null)
 {
     if (0 == count($this->details)) {
         $arrViewType = array('shopIndex');
     } else {
         if (0 < preg_match('/^p\\d+$/', $this->details[count($this->details) - 1])) {
             $arrViewType = array('productDetails');
         } else {
             $arrViewType = array('productCategory', 'productCategory_' . count($this->details));
         }
     }
     $f_pszViewType = $arrViewType[0];
     $objView = AROView::getView($arrViewType, $this->id);
     if (!is_object($objView)) {
         throw new NoTemplateFoundException($arrViewType);
     }
     switch ($arrViewType[0]) {
         case 'productDetails':
             $arrUrl = $this->details;
             $iProductID = substr(array_pop($arrUrl), 1);
             try {
                 $product = AROShopProduct::finder()->byPK($iProductID);
             } catch (Exception $ex) {
                 return -2;
             }
             $parent = $this;
             foreach ($arrUrl as $szCatID) {
                 $parent = $parent->getCategory($szCatID)->init($parent);
                 if (!is_object($parent)) {
                     return -2;
                 }
             }
             $product->init($parent);
             $product->parseView($objView);
             break;
         case 'productCategory':
             $parent = $this;
             $arrUrl = $this->details;
             $lvl = count($arrUrl) + 1;
             foreach ($arrUrl as $szCatID) {
                 $obj = $parent->getCategory($szCatID);
                 $obj->level = $lvl--;
                 if (!is_object($obj)) {
                     return -2;
                 }
                 $obj->init($parent);
                 $parent = $obj;
             }
             $parent->parseView($objView);
             break;
         case 'shopIndex':
             $this->parseView($objView);
             break;
     }
     return true;
 }
 public function parse(&$f_pszViewType = null)
 {
     $szViewType = 'menu';
     $f_pszViewType = $szViewType;
     $objView = AROView::getView($szViewType, $this->id);
     if (!is_object($objView)) {
         throw new NoTemplateFoundException(array($szViewType));
     }
     $this->parseView($objView);
     return true;
 }
Ejemplo n.º 3
0
 public static function getView($f_mvType, $f_szObjectID)
 {
     $arrViewTypes = !is_array($f_mvType) || 1 > count($f_mvType) ? array((string) $f_mvType) : $f_mvType;
     foreach ($arrViewTypes as $szViewType) {
         if (false !== ($iViewId = self::$__db->select_one('specific_view_selections', 'view_id', "object_id = '" . $f_szObjectID . "' AND view_type = '" . $szViewType . "'"))) {
             return AROView::finder()->byPK($iViewId);
         }
         if ($objView = AROView::finder()->findFirst("CONCAT(',',type,',') LIKE ? ORDER BY o ASC", '%,' . $szViewType . ',%')) {
             return $objView;
         }
     }
 }
 public function parse(&$f_pszViewType = null)
 {
     if (0 == count($this->details) || 1 == count($this->details) && 'submit' == $this->details[0]) {
         $szViewType = 'guestbook';
     } else {
         $szViewType = 'guestbookEntry';
     }
     $f_pszViewType = $szViewType;
     $objView = AROView::getView($szViewType, $this->id);
     if (!is_object($objView)) {
         throw new NoTemplateFoundException(array($szViewType));
     }
     $this->guestbook = $this;
     switch ($szViewType) {
         case 'guestbook':
             if (0 < count($this->details) && 'submit' == $this->details[0] && 'POST' == $_SERVER['REQUEST_METHOD']) {
                 $arrShow = self::$m_arrFields;
                 $arrErrors = $arrInsert = array();
                 foreach ($arrShow as $szField) {
                     if ('message' === $szField || '1' === $this->{'use_' . $szField}) {
                         if (('message' == $szField || '1' === $this->{'mandatory_' . $szField}) && (empty($_POST['gb_' . $szField]) || 'email' == $szField && $this->check_email_regexp && !preg_match('/^[a-z0-9\\-_.]{2,}@[a-z0-9\\-_.]{2,}\\.[a-z]{2,10}$/i', $_POST['gb_' . $szField]))) {
                             $arrErrors[$szField] = 'Invalid value';
                         } else {
                             $arrInsert[$szField] = isset($_POST['gb_' . $szField]) ? $_POST['gb_' . $szField] : '';
                         }
                     }
                 }
                 if (0 == count($arrErrors)) {
                     // Insert!
                     $arrInsert['guestbook_implementation_id'] = $this->implementation_id;
                     $arrInsert['utc'] = time();
                     $arrInsert['ip'] = $_SERVER['REMOTE_ADDR'];
                     $arrInsert['o'] = (int) $this->getDbObject()->select_one('guestbook_entries', 'MAX(o)', 'guestbook_implementation_id = ' . $this->implementation_id) + 1;
                     $this->getDbObject()->insert('guestbook_entries', $arrInsert);
                     header('Location: ' . $this->return_url);
                     exit;
                 }
                 $this->errors = $arrErrors;
             }
             $this->parseView($objView);
             break;
         case 'guestbookEntry':
             $entry = $this->getEntry($this->details[0]);
             $entry->parseView($objView);
             break;
     }
     return true;
 }
 public function parse(&$f_pszViewType = null)
 {
     $szViewType = 'page';
     $f_pszViewType = $szViewType;
     $objView = AROView::getView($szViewType, $this->id);
     if (!is_object($objView)) {
         throw new NoTemplateFoundException(array($szViewType));
     }
     $this->init();
     $o = $this;
     $o->root = $this;
     foreach ($this->details as $id) {
         $o = $o->getPage($id);
     }
     $GLOBALS['page'] = $o;
     $o->parseView($objView);
     return true;
 }
 public function parse(&$f_pszViewType = null)
 {
     if (0 < preg_match('#^(\\d+)(?:\\/[^\\/]+)?\\/(\\d+)(?:\\/[^\\/]+)?$#', implode('/', $this->details), $parrMatches)) {
         $szViewType = 'newsItemImage';
         $item = $this->getNewsItem($parrMatches[1])->init($this);
         $object = $item->getImage($parrMatches[2])->init($item);
     } else {
         if (0 < preg_match('#^(\\d+)#', implode('/', $this->details), $parrMatches)) {
             $szViewType = 'newsItem';
             $object = $this->getNewsItem($parrMatches[1])->init($this);
         } else {
             $szViewType = 'newsIndex';
             $object = $this;
         }
     }
     $f_pszViewType = $szViewType;
     $objView = AROView::getView($szViewType, $this->id);
     if (!is_object($objView)) {
         throw new NoTemplateFoundException(array($szViewType));
     }
     $object->parseView($objView);
     return true;
 }
Ejemplo n.º 7
0
<?php

require_once 'cfg_admin.php';
logincheck();
$g_objAdmin->checkEditViewAccess();
$objView = AROView::finder()->byPK($_REQUEST['id']);
$szViewFile = PROJECT_VIEWS . '/' . $objView->id . '.php';
if (!empty($_GET['deleteme'])) {
    $objView->delete();
    unlink($szViewFile);
    header('Location: ../');
    exit;
} else {
    if (isset($_POST['title'], $_POST['content'], $_POST['type'])) {
        require_once PROJECT_INCLUDE . '/Dwoo-1.1.1/Dwoo/dwooAutoload.php';
        $template_source = $_POST['content'];
        $template = new Dwoo_Template_String($template_source);
        $dwoo = new Dwoo();
        $compiler = new Dwoo_Compiler();
        $compiler->setDelimiters('<?', '?>');
        $dwoo->setCompiler($compiler);
        try {
            $compiled_template_source = $dwoo->testTemplate($template);
            //	echo '<pre>'.htmlspecialchars($template_source).'</pre>';
            //	echo '<p>is a valid template:</p>';
            //	exit('<pre>'.htmlspecialchars(file_get_contents($compiled_template_source)).'</pre>');
        } catch (Dwoo_Exception $exc) {
            echo '<pre style="background-color:pink;">' . htmlspecialchars($template_source) . '</pre>';
            echo '<p>is NOT a valid template:</p>';
            exit('<pre style="background-color:pink;">' . $exc->getMessage() . '</pre>');
        }
Ejemplo n.º 8
0
<?php

require_once 'cfg_admin.php';
logincheck();
$g_objAdmin->checkEditViewAccess();
if (isset($_POST['sortorder'])) {
    foreach (explode(',', $_POST['sortorder']) as $o => $vid) {
        $db->update('views', 'o = ' . ($o + 1), 'id = ' . $vid);
    }
    header('Location: ' . $_SERVER['HTTP_REFERER']);
    exit;
}
tpl_header();
echo '<table border="1"><thead><tr><th colspan="4">Templates</th></tr></thead><tbody id="tb_views">';
$arrViews = AROView::finder()->findMany('1 ORDER BY o ASC');
foreach ($arrViews as $view) {
    echo '<tr vid="' . $view->id . '"><th>' . $view->o . '</th><td>' . $view->title . '</td><td>&nbsp;</td><td>' . str_replace(',', ', ', $view->type) . '</td></tr>';
}
echo '</tbody></table>';
?>

<form method="post" action="" onsubmit="this.elements.sortorder.value=getOrder();">
<input type="hidden" name="sortorder" value="" />
<input type="submit" value="Save order" />
</form>
<script type="text/javascript">
function getOrder() {
	return $$('#tb_views tr[vid]').map(function(tr){ return tr.attr('vid'); }).join(',');
}
doMySortable($('tb_views'));
</script>