function smarty_block_navigation($params, $content = '', $template, &$repeat) { if ($repeat) { // Start the navigation ul Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => array('nav')); $f = true; $actions = Clips\get_default($params, 'actions'); if ($actions) { unset($params['actions']); $content = ''; $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } foreach ($actions as $action) { // Only if the object is the valid action if (Clips\valid_obj($action, 'Clips\\Interfaces\\Action')) { $content .= _smarty_block_navigation_tree_node($action, $indent, $template, $repeat, Clips\get_default($params, 'item-class', array())); } } } Clips\context_pop('indent_level'); return Clips\create_tag_with_content('ul', $content, $params, $default); }
public function testRouteResult() { $result = $this->router->routeResult('responsive/size/400/a.jpg'); $this->assertEquals(count($result), 1); $result = $result[0]; $this->assertTrue(Clips\valid_obj($result, 'Clips\\RouteResult')); $this->assertEquals($result->controller, 'Clips\\Controllers\\ResponsiveController'); $this->assertEquals($result->method, 'size'); $this->assertEquals($result->args, array('400', 'a.jpg')); }
protected function _pagi($p, $count = false) { if (\Clips\valid_obj($p, 'Clips\\Pagination')) { // For fields if ($count) { $this->select(array_merge(array('count(*) as count'), $p->fields())); } else { $this->select($p->fields()); } // Check for the table first if (isset($p->from) && $p->from) { $this->from($p->from); } else { \Clips\clips_error("No table to select from!"); return false; } // For where if (isset($p->where) && $p->where) { $this->where($p->where); } // For joins if (isset($p->join) && $p->join) { if (is_array($p->join)) { if (!is_array($p->join[0])) { $p->join = array($p->join); } } foreach ($p->join as $j) { switch (count($j)) { case 0: case 1: \Clips\clips_error("Too few arguments for join!", array($j)); break; case 2: $this->join($j[0], (array) $j[1]); break; default: $this->join($j[0], (array) $j[1], $j[2]); break; } } } // For group bys if (isset($p->groupBy) && $p->groupBy) { $this->groupBy($p->groupBy); } // For order bys if (isset($p->orderBy) && $p->orderBy) { $this->orderBy($p->orderBy); } // For limits if (!$count) { $this->limit($p->offset, $p->length); } return $this->sql(); } return false; }
public function testValidObj() { $obj = new Clips\Commands\VersionCommand(); $this->assertTrue(Clips\valid_obj($obj, "Clips\\Commands\\VersionCommand")); $this->assertTrue(Clips\valid_obj($obj, "Clips\\Command")); }
protected function isWhere($v) { return \Clips\valid_obj($v, 'Clips\\Libraries\\WhereOperator'); }
function smarty_block_action($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'action'); $action = Clips\get_default($params, 'action'); if ($action && Clips\valid_obj($action, 'Clips\\Interfaces\\Action')) { $ps = $action->params(); $icon = $action->icon(); $caption = array(); if ($icon) { $caption[] = Clips\create_tag_with_content('i', '', array('class' => $icon)); $caption[] = Clips\create_tag_with_content('span', $action->label()); if ($action->children()) { $caption[] = Clips\create_tag_with_content('i', '', array('class' => array('fa', 'fa-angle-left', 'pull-right'))); } $caption = implode('', $caption); } else { $caption = $action->label(); } if (!isset($params['title'])) { // Add tooltip $params['title'] = $action->label(); } // This is valid action object switch ($action->type()) { case Action::CLIENT: $params['caption'] = $caption; if ($ps) { foreach ($ps as $k => $v) { $params['data-' . $k] = $v; } } $content = $action->content(); break; case Action::HEADER: return $caption; case Action::SERVER: $content = $caption; if ($ps) { $suffix = implode('/', array_map(function ($item) { return urlencode($item); }, $ps)); $params['uri'] = \Clips\path_join($action->content(), $suffix); } else { $params['uri'] = $action->content(); } break; case Action::EXTERNAL: $content = $caption; $suffix = array(); foreach ($ps as $k => $v) { $suffix[] = urlencode($k) . '=' . urlencode($v); } if ($suffix) { $suffix = implode('&', $suffix); $params['href'] = $action->content() . '?' . $suffix; } else { $params['href'] = $action->content(); } break; } unset($params['action']); } $value = Clips\get_default($params, 'caption'); if ($value) { // We did have value, so the content is the JavaScript $id = Clips\get_default($params, 'id', 'clips_action_' . Clips\sequence('action')); $js = "\$(\"#{$id}\").click(function(){\n\t\t" . trim($content) . "\n\t});"; $content = $template->fetch('string:' . $value); unset($params['caption']); $params['id'] = $id; $params['href'] = 'javascript:void(0)'; Clips\context('jquery_init', $js, true); } else { // Check for action uri $uri = Clips\get_default($params, 'uri'); if ($uri) { $params['href'] = Clips\site_url($uri); unset($params['uri']); } if (!isset($params['title'])) { // Add tooltip $params['title'] = trim($content); } } Clips\context_pop('indent_level'); $bundle_name = Clips\context('current_bundle'); $bundle = Clips\get_default($params, 'bundle', $bundle_name); if ($bundle !== null) { $bundle = Clips\bundle($bundle); $content = $bundle->message($content); } return Clips\create_tag_with_content('a', $content, $params, $default); }