public function render()
 {
     $options = $this->getConfig();
     $field_options = array_get($this->field_config, 'options', array());
     $options = array_merge($options, $field_options);
     // File options
     if ($file_dir = array_get($this->field_config, 'file_dir', false)) {
         $file_dir = trim(array_get($this->field_config, 'file_dir'), '/') . '/';
         $options['fileUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $file_dir;
         $options['fileManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_files?path=' . $file_dir;
         $options['plugins'][] = 'filemanager';
     }
     // Image options
     if ($image_dir = array_get($this->field_config, 'image_dir', false)) {
         $image_dir = trim(array_get($this->field_config, 'image_dir'), '/') . '/';
         $options['imageUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $image_dir;
         $options['imageManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_images?path=' . $image_dir;
         $options['plugins'][] = 'imagemanager';
         if ($resize = array_get($this->field_config, 'resize')) {
             $options['imageUpload'] .= '&resize=1&' . http_build_query($resize);
         }
     }
     // Enable plugins
     $supported_plugins = array('table', 'video', 'fullscreen', 'fontcolor', 'fontsize', 'fontfamily');
     foreach ($options['buttons'] as $button) {
         if (in_array($button, $supported_plugins)) {
             $options['plugins'][] = $button;
         }
     }
     $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'options' => $options);
     $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
     return Parse::template($template, $vars);
 }
コード例 #2
0
 public function __call($method, $arguments)
 {
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     foreach ($extensions as $extension) {
         $full_src = Path::assemble(BASE_PATH, Config::getCurrentThemePath(), 'partials', ltrim($method . $extension, '/'));
         if (File::exists($full_src)) {
             // Merge additional variables passed as parameters
             Statamic_View::$_dataStore = $arguments + Statamic_View::$_dataStore;
             if ($this->fetchParam('use_context', false, false, true, false)) {
                 $html = Parse::contextualTemplate(File::get($full_src), Statamic_View::$_dataStore, $this->context, 'Statamic_View::callback');
             } else {
                 $html = Parse::template(File::get($full_src), Statamic_View::$_dataStore, 'Statamic_View::callback');
             }
             // parse contents if needed
             if ($extension == ".md" || $extension == ".markdown") {
                 $html = Parse::markdown($html);
             } elseif ($extension == ".textile") {
                 $html = Parse::textile($html);
             }
         }
     }
     if (Config::get('enable_smartypants', TRUE)) {
         $html = Parse::smartypants($html);
     }
     return $html;
 }
コード例 #3
0
 public function render()
 {
     $data = $this->field_data ? $this->field_data : array(array('cells' => array('')));
     $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'height' => array_get($this->field_config, 'height'), 'rows' => json_encode($data));
     $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
     return Parse::template($template, $vars);
 }
コード例 #4
0
 /**
  * Lists entries based on passed parameters
  *
  * @return array|string
  */
 public function getContent($variable)
 {
     $urls = array_get($this->context, $variable);
     if (!$urls) {
         return null;
     }
     // grab common parameters
     $settings = $this->parseCommonParameters();
     // grab content set based on the common parameters
     // $content_set = $this->getContentSet($settings);
     $content_set = ContentService::getContentByURL($urls);
     $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false))));
     // limit
     $limit = $this->fetchParam('limit', null, 'is_numeric');
     $offset = $this->fetchParam('offset', 0, 'is_numeric');
     if ($limit || $offset) {
         $content_set->limit($limit, $offset);
     }
     // sort
     $sort_by = $this->fetchParam('sort_by');
     $sort_dir = $this->fetchParam('sort_dir');
     if ($sort_by || $sort_dir) {
         $content_set->sort($sort_by, $sort_dir);
     }
     // check for results
     if (!$content_set->count()) {
         return Parse::template($this->content, array('no_results' => true));
     }
     return Parse::tagLoop($this->content, $content_set->get(), false, $this->context);
 }
コード例 #5
0
ファイル: pi.member.php プロジェクト: nob/joi
 public function profile()
 {
     $current_user = Statamic_Auth::get_current_user() ? Statamic_Auth::get_current_user()->get_name() : false;
     $member = $this->fetchParam('member', $current_user);
     $profile_data = Statamic_user::get_profile($member);
     if ($profile_data) {
         return Parse::template($this->content, $profile_data);
     }
 }
 /**
  * Generate the set templates
  * 
  * @return string  JSON encoded string of templates
  */
 private function setTemplates()
 {
     $template = File::get($this->getAddonLocation() . 'views/templates.html');
     foreach ($this->set_types as $set) {
         $set['buttons'] = $this->buttons;
         $templates[] = array('type' => $set['name'], 'html' => Parse::template($template, $set));
     }
     return json_encode($templates);
 }
コード例 #7
0
ファイル: hooks.file.php プロジェクト: jalmelb/24hl2015
	public function file__thumbnail()
	{
		if ( ! $path = Request::get('path')) {
			exit('No path specified');
		}

		$template = "{{ transform src='{ path }' width='125' height='125' action='smart' }}";

		exit(Parse::template($template, compact('path')));
	}
 public function control_panel__add_to_head()
 {
     if (URL::getCurrent(false) != '/publish' && URL::getCurrent(false) != '/member') {
         return;
     }
     $config = array('max_files' => 1, 'allowed' => array(), 'destination' => 'UPLOAD_PATH', 'browse' => false);
     $fieldtype = Fieldtype::render_fieldtype('file', 'markituploader', $config, null, null, 'markituploader', 'markituploader');
     $template = File::get($this->getAddonLocation() . 'views/modal.html');
     return $this->js->inline('Statamic.markituploader = ' . json_encode(Parse::template($template, compact('fieldtype'))) . ';');
 }
コード例 #9
0
ファイル: tasks.file.php プロジェクト: jalmelb/24hl2015
	public function generateModal($config, $destination)
	{
		$vars = array(
			'server_files' => $this->getServerFiles($config, $destination),
			'destination'  => $destination
		);
		$template = File::get($this->getAddonLocation() . 'views/modal.html');

		return Parse::template($template, $vars);
	}
コード例 #10
0
ファイル: pi.location.php プロジェクト: jalmelb/24hl2015
    public function map_url()
    {
        // parse settings
        $settings = $this->parseParameters();
        
        // we need to set auto_center to false, here's why:
        // this tag will only ever place one marker on the map, and because of
        // the situation, we'll always know its latitude and longitude; by not
        // setting auto_center to false, starting_zoom no longer works (as the
        // auto_center function will try to determine the best zoom within the
        // allowed min_zoom and max_zoom); setting this to false allows users
        // to start using starting_zoom again without having to worry about any
        // automagic stuff taking over and wrestling away control
        $settings['auto_center'] = 'false';
        
        $content_set = ContentService::getContentAsContentSet($settings['url']);
        
        // supplement
        $content_set->supplement(array(
            'locate_with'     => $settings['locate_with'],
            'center_point'    => $settings['center_point'],
            'pop_up_template' => $this->content
        ));

        // re-filter, we only want entries that have been found
        $content_set->filter(array('located' => true));
        $content = $content_set->get();

        // no results? no results.
        if (!count($content)) {
            return Parse::template($this->content, array('no_results' => true));
        }
        
        // check for valid center point
        if (!preg_match(Pattern::COORDINATES, $settings['center_point'], $matches)) {
            if (
                $settings['locate_with'] && 
                isset($content[0][$settings['locate_with']]) && 
                is_array($content[0][$settings['locate_with']]) &&
                isset($content[0][$settings['locate_with']]['latitude']) &&
                isset($content[0][$settings['locate_with']]['longitude'])
            ) {
                $settings['starting_latitude'] = $content[0][$settings['locate_with']]['latitude'];
                $settings['starting_longitude'] = $content[0][$settings['locate_with']]['longitude'];
            }
        } else {
            $settings['starting_latitude']  = $matches[1];
            $settings['starting_longitude'] = $matches[2];
        }
        
        // other overrides
        $settings['clusters'] = 'false';
        
        return $this->buildScript($content, $settings);
    }
コード例 #11
0
ファイル: ft.file.php プロジェクト: jalmelb/24hl2015
	public function render()
	{
		// Let's make sure they set an upload destination
		if (array_get($this->field_config, 'destination', false) === false) {
			throw new Exception("You need to set a destination for your File field.");
		}

		// Normalize the destination
		$this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';

		// Allow a string or an array, but we want an array
		$has_data = ($this->field_data != '');
		$this->field_data = Helper::ensureArray($this->field_data);

		// Clean up {{ _site_root }} and lack of leading slash existence
		foreach ($this->field_data as $i => $file) {
			$this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
		}

		// Whether or not to allow the browse existing files functionality
		$allow_browse = array_get($this->field_config, 'browse', true);

		// Resizing config
		if ($resize = array_get($this->field_config, 'resize')) {
			$resize['resize'] = true;
			$resize = http_build_query($resize);
		}

		// If we're in a subdirectory, prepend it to all the filenames
		if (($site_root = Config::getSiteRoot()) != '/') {
			foreach ($this->field_data as $i => $file) {
				$this->field_data[$i] = URL::assemble($site_root, $file);
			}
		}

		// Send data to the view
		$vars = array(
			'field_id'     => $this->field_id,
			'field_name'   => $this->fieldname,
			'tabindex'     => $this->tabindex,
			'has_data'     => $has_data,
			'field_data'   => $this->field_data,
			'field_config' => $this->field_config,
			'destination'  => $this->destination,
			'allow_browse' => $allow_browse,
			'server_files' => ($allow_browse) ? json_encode($this->tasks->generateModal($this->field_config, $this->destination)) : null,
			'file_thumb'   => URL::assemble(Config::getSiteRoot(), Config::get('admin_path'), 'themes', Config::get('admin_theme'), '/img/file.png'),
			'resize'       => $resize
		);
		$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');

		return Parse::template($template, $vars);
	}
コード例 #12
0
ファイル: pi.truncate.php プロジェクト: nob/joi
 public function words()
 {
     $limit = $this->fetchParam('limit', NULL);
     $ending = $this->fetchParam('ending', '...');
     $this->content = Parse::template($this->content, Statamic_View::$_dataStore, 'Statamic_View::callback');
     $words = preg_split("/[\n\r\t ]+/", $this->content, $limit + 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
     if (count($words) > $limit) {
         end($words);
         $last_word = prev($words);
         $this->content = substr($this->content, 0, $last_word[1] + strlen($last_word[0])) . $ending;
     }
     return $this->content;
 }
コード例 #13
0
ファイル: pi.theme.php プロジェクト: nob/joi
 public function partial()
 {
     $src = $this->fetchParam('src', null, null, false, false);
     if ($src) {
         $src .= ".html";
         $partial_path = $this->theme_root . 'partials/' . ltrim($src, '/');
         if (File::exists($partial_path)) {
             Statamic_View::$_dataStore = array_merge(Statamic_View::$_dataStore, $this->attributes);
             return Parse::template(file_get_contents($partial_path), Statamic_View::$_dataStore, 'Statamic_View::callback');
         }
     }
     return null;
 }
コード例 #14
0
 public function render()
 {
     // Generate a hash unique to this field's config and data
     $hash = Helper::makeHash($this->field_config, $this->field_data);
     // If we've already saved the output, grab it from blink's cache
     // and avoid further processing.
     if ($this->blink->exists($hash)) {
         $html = $this->blink->get($hash);
         return $this->renderFieldReplacements($html);
     }
     // Let's make sure they set an upload destination
     if (array_get($this->field_config, 'destination', false) === false) {
         throw new Exception("You need to set a destination for your File field.");
     }
     // Normalize the destination
     $this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';
     // Allow a string or an array, but we want an array
     $has_data = $this->field_data != '';
     $this->field_data = Helper::ensureArray($this->field_data);
     // Clean up {{ _site_root }} and lack of leading slash existence
     foreach ($this->field_data as $i => $file) {
         $this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
     }
     // Whether or not to allow the browse existing files functionality
     $allow_browse = array_get($this->field_config, 'browse', true);
     // Resizing config
     if ($resize = array_get($this->field_config, 'resize')) {
         $resize['resize'] = true;
         $resize = http_build_query($resize);
     }
     // If we're in a subdirectory, prepend it to all the filenames
     if (($site_root = Config::getSiteRoot()) != '/') {
         foreach ($this->field_data as $i => $file) {
             $this->field_data[$i] = URL::assemble($site_root, $file);
         }
     }
     // Send data to the view
     $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'has_data' => $has_data, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'destination' => $this->destination, 'allow_browse' => $allow_browse, 'browse_url' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path') . '.php/files?config=' . rawurlencode(Helper::encrypt(serialize($this->field_config)))), 'file_thumb' => $this->tasks->defaultFileThumbnail(), 'resize' => $resize);
     // Get the view template from the file
     $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
     // Parse it
     $html = Parse::template($template, $vars);
     // Save it to cache for other similar fields
     $this->blink->set($hash, $html);
     // Output!
     return $this->renderFieldReplacements($html);
 }
コード例 #15
0
ファイル: ft.markitup.php プロジェクト: jalmelb/24hl2015
  public function render()
  {
    $vars = array(
      'field_id'     => $this->field_id,
      'field_name'   => $this->fieldname,
      'tabindex'     => $this->tabindex,
      'field_data'   => $this->field_data,
      'field_config' => $this->field_config,
      'file_dir'     => trim(array_get($this->field_config, 'file_dir'), '/') . '/',
      'image_dir'    => trim(array_get($this->field_config, 'image_dir'), '/') . '/',
      'buttons'      => array_get($this->field_config, 'buttons', $this->config['buttons']),
      'resize'       => array_get($this->field_config, 'resize')
    );

    $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');

    return Parse::template($template, $vars);
  }
コード例 #16
0
ファイル: content.php プロジェクト: Bferreira5/Theme-Example
 /**
  * Parses given $template_data with $data, converts content to $type
  *
  * @param string  $template_data  Template data to parse
  * @param array  $data  List of variables to fill in
  * @param mixed  $type  Optional content type to render
  * @return string
  */
 public static function parse($template_data, $data, $type = NULL)
 {
     $app = \Slim\Slim::getInstance();
     $config = $app->config;
     foreach ($config as $key => $item) {
         if (is_object($item)) {
             unset($config[$key]);
         }
     }
     $data = $data + $config;
     $parse_order = Config::getParseOrder();
     if ($parse_order[0] == 'tags') {
         $output = Parse::template($template_data, $data);
         $output = self::transform($output, $type);
     } else {
         $output = self::transform($template_data, $type);
         $output = Parse::template($output, $data);
     }
     return $output;
 }
コード例 #17
0
 public function partial()
 {
     $start = time();
     $src = $this->fetchParam('src', null, null, false, false);
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     // measurement
     $hash = Debug::markStart('partials', $src, $start);
     Debug::increment('partials', $src);
     if ($src) {
         foreach ($extensions as $extension) {
             $full_src = Path::assemble(BASE_PATH, $this->theme_root, 'partials', ltrim($src . $extension, '/'));
             if (File::exists($full_src)) {
                 Statamic_View::$_dataStore = $this->attributes + Statamic_View::$_dataStore;
                 if ($this->fetchParam('use_context', false, false, true, false)) {
                     // to use context, we only want to pass the attributes as
                     // the current data, as those will override into the context
                     // set of data; if we were to include all of ::$_dataStore,
                     // we run into the issue where all of the global-level variables
                     // are overriding variables in context, when the variables in
                     // context are more accurate scope-wise at this point in the parse
                     $html = Parse::contextualTemplate(file_get_contents($full_src), $this->attributes, $this->context, array('statamic_view', 'callback'), true);
                 } else {
                     $html = Parse::template(file_get_contents($full_src), Statamic_View::$_dataStore);
                 }
                 // parse contents if needed
                 if ($extension == ".md" || $extension == ".markdown") {
                     $html = Parse::markdown($html);
                 } elseif ($extension == ".textile") {
                     $html = Parse::textile($html);
                 }
             }
         }
         if (Config::get('enable_smartypants', TRUE)) {
             $html = Parse::smartypants($html);
         }
     }
     Debug::markEnd($hash);
     return $html;
 }
コード例 #18
0
 public function index()
 {
     // Params
     // 5th parameter on path prevents forcing filename to lowercase
     $path = $this->fetchParam('path', null, null, false, false);
     $type = $this->fetchParam('type');
     // width or height
     $divide = (int) $this->fetchParam('divide');
     $parse_path = $this->fetchParam('parse_path');
     // Find out if we need to parse a plugin in the path parameter
     if ($parse_path == 'yes') {
         $path = Parse::template('{' . $path . '}', array());
     }
     // Make sure path and type params have been set
     if ($path != '' and $type != '') {
         $fullPath = $_SERVER['DOCUMENT_ROOT'] . $path;
         // Make sure the path to the file is valid first
         if (file_exists($fullPath)) {
             list($width, $height) = getimagesize($fullPath);
             if ($divide != '') {
                 $width = $width / $divide;
                 $height = $height / $divide;
             }
             // Determine if width or height
             if ($type == 'height') {
                 return $height;
             } elseif ($type == 'width') {
                 return $width;
             } else {
                 return 'incorrect type param';
             }
             // Return incorrect path if the path is not valid
         } else {
             return 'incorrect path';
         }
         // If path and type params have not been set, return an error
     } else {
         return 'missing parameter';
     }
 }
コード例 #19
0
ファイル: parse.php プロジェクト: nob/joi
 /**
  * Parses a tag loop, replacing template variables with each array in a list of arrays
  *
  * @param string  $content  Template for replacing
  * @param array  $data  Array of arrays containing values
  * @return string
  */
 public static function tagLoop($content, $data)
 {
     $output = "";
     // loop through each record of $data
     foreach ($data as $item) {
         $item_content = $content;
         // replace all inline instances of { variable } with the variable's value
         if (preg_match_all(Pattern::TAG, $item_content, $data_matches, PREG_SET_ORDER + PREG_OFFSET_CAPTURE)) {
             foreach ($data_matches as $match) {
                 $tag = $match[0][0];
                 $name = $match[1][0];
                 if (isset($item[$name])) {
                     $item_content = str_replace($tag, $item[$name], $item_content);
                 }
             }
         }
         // add this record's parsed template to the output string
         $output .= Parse::template($item_content, $item);
     }
     // return what we've parsed
     return $output;
 }
 /**
  * Add the modal to the footer
  *
  * @return string
  */
 public function control_panel__add_to_foot()
 {
     // don't do anything on the login screen
     if (Request::getResourceURI() == '/login') {
         return false;
     }
     // master switch for revisions
     if (!$this->core->isEnabled()) {
         return false;
     }
     if (!URL::getCurrent() == '/publish') {
         return false;
     }
     $path = $this->core->getPath();
     $view_data = array('revisions' => $this->core->getRevisions($path), 'path' => $path);
     // revision selector
     $view = File::get($this->getAddonLocation() . 'views/modal.html');
     $html = Parse::template($view, $view_data);
     // revision message
     $view = File::get($this->getAddonLocation() . 'views/commit_modal.html');
     $html .= Parse::template($view, $view_data);
     return $html;
 }
 public function member__forgot_password()
 {
     $globals = Statamic::loadAllConfigs();
     $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
     $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING);
     $return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_STRING);
     $reset_return = filter_input(INPUT_POST, 'reset_return', FILTER_SANITIZE_STRING);
     $referrer = Request::getReferrer();
     // validate form token
     if (!$this->tokens->validate($token)) {
         $this->flash->set('forgot_password_error', 'Invalid token.');
         URL::redirect($referrer);
     }
     // bail if member doesn't exist
     if (!($member = Member::load($username))) {
         $this->flash->set('forgot_password_error', Localization::fetch('member_doesnt_exist'));
         URL::redirect($referrer);
     }
     // cache reset data
     $token = $this->tokens->create();
     $reset_data = array('username' => $username);
     if (isset($reset_return)) {
         $reset_data['return'] = $reset_return;
     }
     $this->cache->putYAML($token, $reset_data);
     // generate reset url
     $reset_url = URL::makeFull($this->fetchConfig('reset_password_url', str_replace(Config::getSiteURL(), '', $referrer)));
     $reset_url .= '?H=' . $token;
     // send email
     $attributes = array('from' => $this->fetchConfig('email_sender', Config::get('email_sender'), null, false, false), 'to' => $member->get('email'), 'subject' => $this->fetchConfig('reset_password_subject', 'Password Reset', null, false, false));
     if ($html_template = $this->fetchConfig('reset_password_html_email', false, null, false, false)) {
         $attributes['html'] = Theme::getTemplate($html_template);
     }
     if ($text_template = $this->fetchConfig('reset_password_text_email', false, null, false, false)) {
         $attributes['text'] = Theme::getTemplate($text_template);
     }
     foreach ($attributes as $key => $value) {
         $attributes[$key] = Parse::template($value, array('reset_url' => $reset_url), array('statamic_view', 'callback'), $globals);
     }
     Email::send($attributes);
     $this->flash->set('forgot_password_sent', true);
     // redirect
     URL::redirect($return);
 }
コード例 #22
0
 public function pagination()
 {
     // grab common parameters
     $settings = $this->parseCommonParameters();
     // grab member set based on the common parameters
     $member_set = $this->getMemberSet($settings);
     // grab limit as page size
     $limit = $this->fetchParam('limit', null, 'is_numeric');
     // defaults to none
     // count the content available
     $count = $member_set->count();
     $pagination_variable = Config::getPaginationVariable();
     $page = Request::get($pagination_variable, 1);
     $data = array();
     $data['total_items'] = (int) max(0, $count);
     $data['items_per_page'] = (int) max(1, $limit);
     $data['total_pages'] = (int) ceil($count / $limit);
     $data['current_page'] = (int) min(max(1, $page), max(1, $page));
     $data['current_first_item'] = (int) min(($page - 1) * $limit + 1, $count);
     $data['current_last_item'] = (int) min($data['current_first_item'] + $limit - 1, $count);
     $data['previous_page'] = $data['current_page'] > 1 ? "?{$pagination_variable}=" . ($data['current_page'] - 1) : false;
     $data['next_page'] = $data['current_page'] < $data['total_pages'] ? "?{$pagination_variable}=" . ($data['current_page'] + 1) : false;
     $data['first_page'] = $data['current_page'] === 1 ? false : "?{$pagination_variable}=1";
     $data['last_page'] = $data['current_page'] >= $data['total_pages'] ? false : "?{$pagination_variable}=" . $data['total_pages'];
     $data['offset'] = (int) (($data['current_page'] - 1) * $limit);
     return Parse::template($this->content, $data);
 }
コード例 #23
0
 public function pagination()
 {
     // grab common parameters
     $settings = $this->parseCommonParameters();
     // grab member set based on the common parameters
     $member_set = $this->getMemberSet($settings);
     // grab limit as page size
     $limit = $this->fetchParam('limit', null, 'is_numeric');
     // defaults to none
     // count the content available
     $count = $member_set->count();
     $data = Helper::createPaginationData($count, $limit);
     return Parse::template($this->content, $data);
 }
コード例 #24
0
ファイル: pi.raven.php プロジェクト: jalmelb/24hl2015
	/**
	* Returns an array if errors are present, false if not
	*
	* Set in hooks.raven.php -> process()
	*
	* @return mixed
	**/
	public function errors()
	{
		if ( ! $this->isActiveForm()) {
			return false;
		}

		if ($errors = $this->flash->get('errors')) {
			return Parse::template($this->content, $errors);
		}

		return false;
	}
コード例 #25
0
 private function getTransformedImage($path, $width = 125, $height = 125)
 {
     $path = URL::prependSiteRoot($path);
     $template = "{{ transform src='{$path}' width='{$width}' height='{$height}' action='smart' }}";
     return Parse::template($template, array());
 }
コード例 #26
0
ファイル: hooks.raven.php プロジェクト: jeffreyDcreative/gkp
 /**
  * Send a notification/response email
  *
  * @param array  $submission  Array of submitted values
  * @param array  $config  Array of config values
  * @return void
  */
 private function send($submission, $config)
 {
     if (array_get($this->config, 'master_killswitch')) {
         return;
     }
     $email = array_get($config, 'email', false);
     if ($email) {
         $attributes = array_intersect_key($email, array_flip(Email::$allowed));
         if (array_get($email, 'automagic') || array_get($email, 'automatic')) {
             $automagic_email = $this->buildAutomagicEmail($submission);
             $attributes['html'] = $automagic_email['html'];
             $attributes['text'] = $automagic_email['text'];
         }
         if ($html_template = array_get($email, 'html_template', false)) {
             $attributes['html'] = Theme::getTemplate($html_template);
         }
         if ($text_template = array_get($email, 'text_template', false)) {
             $attributes['text'] = Theme::getTemplate($text_template);
         }
         /*
         |--------------------------------------------------------------------------
         | Parse all fields
         |--------------------------------------------------------------------------
         |
         | All email settings are parsed with the form data, allowing you, for
         | example, to send an email to a submitted email address.
         |
         |
         */
         foreach ($attributes as $key => $value) {
             $attributes[$key] = Parse::template($value, $submission);
         }
         $attributes['email_handler'] = array_get($config, 'email_handler', false);
         $attributes['email_handler_key'] = array_get($config, 'email_handler_key', false);
         Email::send($attributes);
     }
 }
コード例 #27
0
 /**
  * Filters the current users based on the filters given
  * 
  * @param array  $filters  Filters to apply
  * @return void
  */
 public function filter($filters)
 {
     $filters = Helper::ensureArray($filters);
     // nothing to filter, abort
     if (!$this->count()) {
         return;
     }
     $roles = null;
     $conditions = null;
     $where = null;
     // standardize filters
     $given_filters = $filters;
     $filters = array('role' => isset($given_filters['role']) ? $given_filters['role'] : null, 'conditions' => isset($given_filters['conditions']) ? $given_filters['conditions'] : null, 'where' => isset($given_filters['where']) ? $given_filters['where'] : null);
     // determine filters
     if ($filters['role']) {
         $roles = Parse::pipeList($filters['role']);
     }
     if ($filters['conditions']) {
         $conditions = Parse::conditions($filters['conditions']);
     }
     if ($filters['where']) {
         $where = $filters['where'];
     }
     // run filters
     foreach ($this->members as $username => $data) {
         if ($roles) {
             $found = false;
             foreach ($roles as $role) {
                 if (in_array($role, $data['roles'])) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 unset($this->members[$username]);
                 continue;
             }
         }
         if ($where && !(bool) Parse::template("{{ if " . $where . " }}1{{ else }}0{{ endif }}", $data)) {
             unset($this->members[$username]);
             continue;
         }
         if ($conditions) {
             foreach ($conditions as $field => $instructions) {
                 try {
                     // are we looking for existence?
                     if ($instructions['kind'] === "existence") {
                         if ($instructions['type'] === "has") {
                             if (!isset($data[$field]) || !$data[$field]) {
                                 throw new Exception("Does not fit condition");
                             }
                         } elseif ($instructions['type'] === "lacks") {
                             if (isset($data[$field]) && $data[$field]) {
                                 throw new Exception("Does not fit condition");
                             }
                         } else {
                             throw new Exception("Unknown existence type");
                         }
                         // are we looking for a comparison?
                     } elseif ($instructions['kind'] === "comparison") {
                         if (!isset($data[$field])) {
                             $field = false;
                             $values = null;
                         } else {
                             $field = is_array($data[$field]) ? array_map('strtolower', $data[$field]) : strtolower($data[$field]);
                             $values = is_array($instructions['value']) ? array_map('strtolower', $instructions['value']) : strtolower($instructions['value']);
                         }
                         // convert boolean-like statements to boolean values
                         if (is_array($values)) {
                             foreach ($values as $item => $value) {
                                 if ($value == "true" || $value == "yes") {
                                     $values[$item] = true;
                                 } elseif ($value == "false" || $value == "no") {
                                     $values[$item] = false;
                                 }
                             }
                         } else {
                             if ($values == "true" || $values == "yes") {
                                 $values = true;
                             } elseif ($values == "false" || $values == "no") {
                                 $values = false;
                             }
                         }
                         // equal comparisons
                         if ($instructions['type'] == "equal") {
                             // if this isn't set, it's not equal
                             if (!$field) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (!is_array($field)) {
                                 if ($field != $values) {
                                     throw new Exception("Does not fit condition");
                                 }
                             } elseif (!in_array($values, $field)) {
                                 throw new Exception("Does not fit condition");
                             }
                             // greater than or equal to comparisons
                         } elseif ($instructions['type'] == "greater than or equal to") {
                             // if this isn't set, it's not greater than or equal to
                             if (!$field) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field) || is_array($values) || !is_numeric($field) || !is_numeric($values) || $field < $values) {
                                 throw new Exception("Does not fit condition");
                             }
                             // greater than to comparisons
                         } elseif ($instructions['type'] == "greater than") {
                             // if this isn't set, it's not less than
                             if (!$field) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field) || is_array($values) || !is_numeric($field) || !is_numeric($values) || $field <= $values) {
                                 throw new Exception("Does not fit condition");
                             }
                             // less than or equal to comparisons
                         } elseif ($instructions['type'] == "less than or equal to") {
                             // if this isn't set, it's not less than or equal to
                             if (!$field) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field) || is_array($values) || !is_numeric($field) || !is_numeric($values) || $field > $values) {
                                 throw new Exception("Does not fit condition");
                             }
                             // less than to comparisons
                         } elseif ($instructions['type'] == "less than") {
                             // if this isn't set, it's not less than
                             if (!$field) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field) || is_array($values) || !is_numeric($field) || !is_numeric($values) || $field >= $values) {
                                 throw new Exception("Does not fit condition");
                             }
                             // not-equal comparisons
                         } elseif ($instructions['type'] == "not equal") {
                             // if this isn't set, it's not equal, continue
                             if (!$field) {
                                 continue;
                             }
                             if (!is_array($field)) {
                                 if ($field == $values) {
                                     throw new Exception("Does not fit condition");
                                 }
                             } elseif (in_array($values, $field)) {
                                 throw new Exception("Does not fit condition");
                             }
                             // contains comparisons
                         } elseif ($instructions['type'] == "in") {
                             if (!isset($field)) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field)) {
                                 $found = false;
                                 foreach ($field as $option) {
                                     if (in_array($option, $values)) {
                                         $found = true;
                                         break;
                                     }
                                 }
                                 if (!$found) {
                                     throw new Exception("Does not fit condition");
                                 }
                             } elseif (!in_array($field, $values)) {
                                 throw new Exception("Does not fit condition");
                             }
                         } elseif ($instructions['type'] == "not in") {
                             if (!isset($field)) {
                                 throw new Exception("Does not fit condition");
                             }
                             if (is_array($field)) {
                                 foreach ($field as $option) {
                                     if (in_array($option, $values)) {
                                         throw new Exception("Does not fit condition");
                                     }
                                 }
                             } elseif (in_array($field, $values)) {
                                 throw new Exception("Does not fit condition");
                             }
                         }
                         // we don't know what this is
                     } else {
                         throw new Exception("Unknown kind of condition");
                     }
                 } catch (Exception $e) {
                     unset($this->members[$username]);
                     continue;
                 }
             }
         }
     }
 }
コード例 #28
0
ファイル: pi.nav.php プロジェクト: zane-insight/WhiteLaceInn
 public function count()
 {
     // grab parameters
     $from = $this->fetchParam('from', URL::getCurrent());
     $exclude = $this->fetchParam('exclude', false);
     $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric');
     $include_entries = $this->fetchParam('include_entries', false, false, true);
     $folders_only = $this->fetchParam('folders_only', true, false, true);
     $include_content = $this->fetchParam('include_content', false, false, true);
     $show_hidden = $this->fetchParam('show_hidden', false, null, true);
     // add in left-/ if not present
     if (substr($from, 0, 1) !== '/') {
         $from = '/' . $from;
     }
     // if this doesn't start with the site root, add the site root
     if (!Pattern::startsWith($from, Config::getSiteRoot())) {
         $from = Path::tidy(Config::getSiteRoot() . '/' . $from);
     }
     // standardize excludes
     if ($exclude && !is_array($exclude)) {
         $exclude = Helper::explodeOptions($exclude, array());
         foreach ($exclude as $key => $value) {
             $exclude[$key] = Path::tidy(Config::getSiteRoot() . '/' . $value);
         }
     }
     // option hash
     $hash = Helper::makeHash($from, $exclude, $max_depth, $include_entries, $folders_only, $include_content, $show_hidden);
     // load the content tree from cache
     if ($this->blink->exists($hash)) {
         $tree = $this->blink->get($hash);
     } else {
         $tree = ContentService::getContentTree($from, $max_depth, $folders_only, $include_entries, $show_hidden, $include_content, $exclude);
         $this->blink->set($hash, $tree);
     }
     if ($this->content) {
         return Parse::template($this->content, array('count' => count($tree)));
     } elseif (count($tree)) {
         return count($tree);
     }
     return '';
 }
コード例 #29
0
ファイル: pi.entries.php プロジェクト: jalmelb/24hl2015
    /**
     * Display the previous entry listing for the settings provided based $current URL
     *
     * @param array  $passed_settings  Optional passed settings for reusing methods
     * @param boolean  $check_for_next  Should we check for next values?
     * @param boolean  $wrap_around  If there's no previous, return the last item?
     * @return array
     */
    public function previous($passed_settings=null, $check_for_next=true, $wrap_around=null)
    {
        // grab common parameters
        $settings = Helper::pick($passed_settings, $this->parseCommonParameters());

        // grab content set based on the common parameters
        $content_set = $this->getContentSet($settings);

        // what is our base point?
        $current = $this->fetch('current', URL::getCurrent(), false, false, false);

        // should we wrap around?
        $wrap_around = Helper::pick($wrap_around, $this->fetch('wrap', false, false, true, false));

        // check for has_next, used for method interoperability
        if ($check_for_next) {
            $next = $this->next($settings, false, $wrap_around);
            $has_next = !is_array($next);
        } else {
            $has_next = false;
        }

        // if current wasn't set, we can't determine the previous content
        if (!$current) {
            return array('no_results' => true, 'has_next' => $has_next);
        }

        // get the content
        $content = $content_set->get(preg_match(Pattern::USING_CONTENT, $this->content));

        // set up iterator variables
        $previous_data = null;
        $output_data   = null;

        // loop through content looking for current
        if (!empty($content)) {
            foreach ($content as $item) {
                // this should never happen, but just in case
                if (!isset($item['url'])) {
                    continue;
                }

                if ($item['url'] == $current) {
                    $output_data = $previous_data;
                    break;
                }

                // wasn't a match, set this item as previous data and do it again
                $previous_data = $item;
            }
        }

        // wrap around?
        if ($wrap_around && is_array($content) && !empty($content) && (!$output_data || !is_array($output_data))) {
            $output_data = array_pop($content);
        }

        // if no $output_data was found, tell'em so
        if (!$output_data || !is_array($output_data)) {
            return array('no_results' => true, 'has_next' => $has_next);
        }

        // does this context have a previous?
        $output_data['has_next'] = $has_next;

        // return the found data
        return Parse::template($this->content, $output_data);
    }
コード例 #30
0
 /**
  * Filters the current content set down based on the filters given
  *
  * @param array  $filters  Filters to use to narrow down content
  * @return void
  * @throws Exception
  */
 public function filter($filters)
 {
     $hash = Debug::markStart('content', 'filtering');
     $filters = Helper::ensureArray($filters);
     // nothing to filter, abort
     if (!$this->count()) {
         return;
     }
     $since_date = null;
     $until_date = null;
     $remove_hidden = null;
     $remove_drafts = null;
     $keep_type = "all";
     $folders = null;
     $conditions = null;
     $located = false;
     $where = null;
     // standardize filters
     // -------------------
     $given_filters = $filters;
     $filters = array('show_hidden' => isset($given_filters['show_hidden']) ? $given_filters['show_hidden'] : null, 'show_drafts' => isset($given_filters['show_drafts']) ? $given_filters['show_drafts'] : null, 'since' => isset($given_filters['since']) ? $given_filters['since'] : null, 'until' => isset($given_filters['until']) ? $given_filters['until'] : null, 'show_past' => isset($given_filters['show_past']) ? $given_filters['show_past'] : null, 'show_future' => isset($given_filters['show_future']) ? $given_filters['show_future'] : null, 'type' => isset($given_filters['type']) ? strtolower($given_filters['type']) : null, 'folders' => isset($given_filters['folders']) ? $given_filters['folders'] : null, 'conditions' => isset($given_filters['conditions']) ? $given_filters['conditions'] : null, 'located' => isset($given_filters['located']) ? $given_filters['located'] : null, 'where' => isset($given_filters['where']) ? $given_filters['where'] : null);
     // determine filters
     // -----------------
     if (!is_null($filters['show_hidden'])) {
         $remove_hidden = !(bool) $filters['show_hidden'];
     }
     if (!is_null($filters['show_drafts'])) {
         $remove_drafts = !(bool) $filters['show_drafts'];
     }
     if ($filters['since']) {
         $since_date = Date::resolve($filters['since']);
     }
     if ($filters['show_past'] === false && (!$since_date || $since_date < time())) {
         $since_date = Config::getEntryTimestamps() ? time() : Date::resolve("today midnight");
     }
     if ($filters['until']) {
         $until_date = Date::resolve($filters['until']);
     }
     if ($filters['show_future'] === false && (!$until_date || $until_date > time())) {
         $until_date = Config::getEntryTimestamps() ? time() : Date::resolve("tomorrow midnight") - 1;
     }
     if ($filters['type'] === "entries" || $filters['type'] === "pages") {
         $keep_type = $filters['type'];
     }
     if ($filters['folders']) {
         $folders = Parse::pipeList($filters['folders']);
     }
     if ($filters['conditions']) {
         $conditions = Parse::conditions($filters['conditions']);
     }
     if ($filters['located']) {
         $located = true;
     }
     if ($filters['where']) {
         $where = $filters['where'];
     }
     // before we run filters, we need to look through conditions if they
     // were set to see if we're going to need content or content_raw
     // -----------
     if ($conditions) {
         // check for conditions involving content
         $uses_content = false;
         foreach ($conditions as $field => $instructions) {
             if (strtolower($field) === 'content') {
                 $uses_content = true;
                 break;
             }
         }
         // this uses content, which means we need to load it for all content
         if ($uses_content) {
             $this->prepare(true, false);
             $this->content_parsed = false;
         }
     }
     // run filters
     // -----------
     foreach ($this->content as $key => $data) {
         // entry or page removal
         if ($keep_type === "pages" && !$data['_is_page']) {
             unset($this->content[$key]);
             continue;
         } elseif ($keep_type === "entries" && !$data['_is_entry']) {
             unset($this->content[$key]);
             continue;
         }
         // check for non-public content
         if ($remove_drafts && $data['_is_draft']) {
             unset($this->content[$key]);
             continue;
         }
         if ($remove_hidden && $data['_is_hidden']) {
             unset($this->content[$key]);
             continue;
         }
         // folder
         if ($folders) {
             $keep = false;
             foreach ($folders as $folder) {
                 if ($folder === "*" || $folder === "/*") {
                     // include all
                     $keep = true;
                     break;
                 } elseif (substr($folder, -1) === "*") {
                     // wildcard check
                     if (strpos($data['_folder'], substr($folder, 0, -1)) === 0) {
                         $keep = true;
                         break;
                     }
                 } else {
                     // plain check
                     if ($folder == $data['_folder']) {
                         $keep = true;
                         break;
                     }
                 }
             }
             if (!$keep) {
                 unset($this->content[$key]);
                 continue;
             }
         }
         // since & show past
         if ($since_date && $data['datestamp'] && $data['datestamp'] < $since_date) {
             unset($this->content[$key]);
             continue;
         }
         // until & show future
         if ($until_date && $data['datestamp'] && $data['datestamp'] > $until_date) {
             unset($this->content[$key]);
             continue;
         }
         // where
         if ($where && !(bool) Parse::template("{{ if " . $where . " }}1{{ else }}0{{ endif }}", $data)) {
             unset($this->content[$key]);
             continue;
         }
         // conditions
         if ($conditions) {
             $case_sensitive_taxonomies = Config::getTaxonomyCaseSensitive();
             foreach ($conditions as $field => $instructions) {
                 $optional = substr($field, -1, 1) == '?';
                 $field = $optional ? trim(substr($field, 0, -1)) : $field;
                 try {
                     // are we looking for existence?
                     if ($instructions['kind'] === "existence") {
                         if ($instructions['type'] === "has") {
                             if (!isset($data[$field]) || !$data[$field]) {
                                 throw new Exception("Does not fit condition");
                             }
                         } elseif ($instructions['type'] === "lacks") {
                             if (isset($data[$field]) && $data[$field]) {
                                 throw new Exception("Does not fit condition");
                             }
                         } else {
                             throw new Exception("Unknown existence type");
                         }
                         // are we looking for a comparison?
                     } elseif ($instructions['kind'] === "comparison") {
                         $is_taxonomy = Taxonomy::isTaxonomy($field);
                         $case_sensitive = $is_taxonomy && $case_sensitive_taxonomies;
                         if (!isset($data[$field])) {
                             $field = false;
                             $values = null;
                         } else {
                             if ($case_sensitive) {
                                 $field = $data[$field];
                                 $values = $instructions['value'];
                             } else {
                                 $field = is_array($data[$field]) ? array_map('strtolower', $data[$field]) : strtolower($data[$field]);
                                 $values = is_array($instructions['value']) ? array_map('strtolower', $instructions['value']) : strtolower($instructions['value']);
                             }
                         }
                         // convert boolean-like statements to boolean values
                         if (is_array($values)) {
                             foreach ($values as $item => $value) {
                                 if ($value == "true" || $value == "yes") {
                                     $values[$item] = true;
                                 } elseif ($value == "false" || $value == "no") {
                                     $values[$item] = false;
                                 }
                             }
                         } else {
                             if ($values == "true" || $values == "yes") {
                                 $values = true;
                             } elseif ($values == "false" || $values == "no") {
                                 $values = false;
                             }
                         }
                         // convert date-like statements to timestamps for qualitative comparisons (not equals)
                         if (in_array($instructions['type'], array('greater than or equal to', 'greater than', 'less than or equal to', 'less than'))) {
                             if (!is_array($field) && !is_numeric($field) && Date::resolve($field) !== false) {
                                 $field = Date::resolve($field);
                             }
                             if (!is_array($values) && !is_numeric($values) && Date::resolve($values) !== false) {
                                 $values = Date::resolve($values);
                             }
                         }
                         // equal comparisons
                         if ($instructions['type'] == "equal") {
                             // if this isn't set, it's not equal
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (!is_array($field)) {
                                 if ($field != $values) {
                                     throw new Exception("Does not fit condition", 0);
                                 }
                             } elseif (!in_array($values, $field)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // greater than or equal to comparisons
                         } elseif ($instructions['type'] == "greater than or equal to") {
                             // if this isn't set, it's not greater than or equal to
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (is_array($field) || is_array($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             if (!is_numeric($field) && Date::resolve($field) !== false) {
                                 $field = Date::resolve($field);
                             }
                             if (!is_numeric($values) && Date::resolve($values) !== false) {
                                 $values = Date::resolve($values);
                             }
                             if (!is_numeric($field) || !is_numeric($values) || $this->toNumber($field) < $this->toNumber($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // greater than to comparisons
                         } elseif ($instructions['type'] == "greater than") {
                             // if this isn't set, it's not less than
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (is_array($field) || is_array($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             if (!is_numeric($field) && Date::resolve($field) !== false) {
                                 $field = Date::resolve($field);
                             }
                             if (!is_numeric($values) && Date::resolve($values) !== false) {
                                 $values = Date::resolve($values);
                             }
                             if (!is_numeric($field) || !is_numeric($values) || $this->toNumber($field) <= $this->toNumber($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // less than or equal to comparisons
                         } elseif ($instructions['type'] == "less than or equal to") {
                             // if this isn't set, it's not less than or equal to
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (is_array($field) || is_array($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             if (!is_numeric($field) && Date::resolve($field) !== false) {
                                 $field = Date::resolve($field);
                             }
                             if (!is_numeric($values) && Date::resolve($values) !== false) {
                                 $values = Date::resolve($values);
                             }
                             if (!is_numeric($field) || !is_numeric($values) || $this->toNumber($field) > $this->toNumber($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // less than to comparisons
                         } elseif ($instructions['type'] == "less than") {
                             // if this isn't set, it's not less than
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (is_array($field) || is_array($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             if (!is_numeric($field) && Date::resolve($field) !== false) {
                                 $field = Date::resolve($field);
                             }
                             if (!is_numeric($values) && Date::resolve($values) !== false) {
                                 $values = Date::resolve($values);
                             }
                             if (!is_numeric($field) || !is_numeric($values) || $this->toNumber($field) >= $this->toNumber($values)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // not-equal comparisons
                         } elseif ($instructions['type'] == "not equal") {
                             // if this isn't set, it's not equal, continue
                             if (!$field) {
                                 continue;
                             }
                             if (!is_array($field)) {
                                 if ($field == $values) {
                                     throw new Exception("Does not fit condition", 0);
                                 }
                             } elseif (in_array($values, $field)) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // contains array comparisons
                         } elseif ($instructions['type'] == "in") {
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (!count(array_intersect(Helper::ensureArray($field), $values))) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // doesn't contain array comparisons
                         } elseif ($instructions['type'] == "not in") {
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             if (count(array_intersect(Helper::ensureArray($field), $values))) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                             // contains contains-text comparisons
                         } elseif ($instructions['type'] == 'contains text') {
                             if (!$field) {
                                 throw new Exception("Field not set", 1);
                             }
                             $field = Helper::ensureArray($field);
                             $found = false;
                             foreach ($field as $option) {
                                 // do we need to loop through values?
                                 if (is_array($values)) {
                                     // we do
                                     foreach ($values as $value) {
                                         if (strpos($option, strtolower($value)) !== false) {
                                             $found = true;
                                             break;
                                         }
                                     }
                                     if ($found) {
                                         break;
                                     }
                                 } else {
                                     // we don't
                                     if (strpos($option, strtolower($values)) !== false) {
                                         $found = true;
                                         break;
                                     }
                                 }
                             }
                             if (!$found) {
                                 throw new Exception("Does not fit condition", 0);
                             }
                         }
                         // we don't know what this is
                     } else {
                         throw new Exception("Unknown kind of condition", -1);
                     }
                 } catch (Exception $e) {
                     if ($optional && $e->getCode() === 1) {
                         // we were only making the comparison if the field exists,
                         // otherwise, this is ok
                         continue;
                     }
                     // this was not an optional field, and something went wrong
                     unset($this->content[$key]);
                     continue;
                 }
             }
         }
         // located
         if ($located && !isset($data['coordinates'])) {
             unset($this->content[$key]);
             continue;
         }
     }
     Debug::markEnd($hash);
 }