loopKeywords['orderDesc'] = 'reversed'; $this->loopKeywords['orderBy'] = 'by'; $this->loopKeywords['begin'] = 'begin'; $this->loopTagName = 'LOOP'; $this->loopShortTagName = 'L'; $this->fotoo =& $fotoo; } protected function processLoopType_directories($criterias, $content) { $dir = ''; $order = 1; foreach ($criterias as $criteria) { switch ($criteria['action']) { case miniSkel::ACTION_ORDER_DESC: $order = 0; break; case miniSkel::ACTION_MATCH_FIELD: case miniSkel::ACTION_MATCH_FIELD_BY_VALUE: { if ($criteria['field'] != 'dir') continue(2); if (!isset($criteria['value']) && isset($_REQUEST[$criteria['field']])) $criteria['value'] = $_REQUEST[$criteria['field']]; if (empty($criteria['value'])) continue(2); $dir = $criteria['value']; break; } default: break; } } $dirs = $this->fotoo->getDirectory($dir, true, false); if (empty($dirs)) return false; if ($order) ksort($dirs); else krsort($dirs); foreach ($dirs as $dir) { $out .= $this->parseVariables($content, array('name' => $dir)); } $out = $this->parseVariables($out, array('current_dir' => $dir)); return $out; } protected function processLoopType_update($criterias, $content) { $dir = ''; foreach ($criterias as $criteria) { switch ($criteria['action']) { case miniSkel::ACTION_MATCH_FIELD: case miniSkel::ACTION_MATCH_FIELD_BY_VALUE: { if ($criteria['field'] != 'dir') continue(2); if (!isset($criteria['value']) && isset($_REQUEST[$criteria['field']])) $criteria['value'] = $_REQUEST[$criteria['field']]; if (empty($criteria['value'])) continue(2); $dir = $criteria['value']; break; } default: break; } } $files = $this->fotoo->getDirectory($dir, false, true); if (empty($files)) return false; $out = "\n" . ''; return $out; } protected function processLoopType_photos($criterias, $content) { $query = 'SELECT photos.* FROM photos LEFT JOIN tags ON tags.photo = photos.id '; $where = 'WHERE 1'; $order = ''; $limit = ''; foreach ($criterias as $criteria) { switch ($criteria['action']) { case miniSkel::ACTION_ORDER_BY: if (!$order) $order = 'ORDER BY '.$criteria['field'].''; else $order .= ', '.$criteria['field'].''; break; case miniSkel::ACTION_ORDER_DESC: if ($order) $order .= ' DESC'; break; case miniSkel::ACTION_LIMIT: $limit = 'LIMIT '.$criteria['begin'].','.$criteria['number']; break; case miniSkel::ACTION_MATCH_FIELD: case miniSkel::ACTION_MATCH_FIELD_BY_VALUE: { if (!isset($criteria['value']) && isset($_REQUEST[$criteria['field']])) $criteria['value'] = $_REQUEST[$criteria['field']]; if ($criteria['field'] == 'tag') $criteria['field'] = 'tags.name'; elseif ($criteria['field'] == 'dir') $criteria['field'] = 'photos.path'; else $criteria['field'] = 'photos.' . $criteria['field']; if (!isset($criteria['comparison'])) $criteria['comparison'] = '='; if (!isset($criteria['value'])) continue(2); $where .= ' AND '.$criteria['field'].' '.$criteria['comparison'].' \''. sqlite_escape_string($criteria['value']) . '\' '; break; } default: break; } } if (!$limit) $limit = 'LIMIT 0,100'; $query .= $where . ' ' . $order . ' ' .$limit; #die($query); $articles = $this->fotoo->db->arrayQuery($query, SQLITE_ASSOC); foreach ($articles as $art) { $out .= $this->parseVariables($content, $art); } return $out; } } $tpl = new fotooSkel($f); $tpl->template_path = BASE_DIR . '/templates/'; $tpl->assign('site_title', GALLERY_TITLE); ?>