function AddHeaderfiles($addcode, $sep, $sepmed, $mediadefault)
 {
     global $modx;
     if (strpos(strtolower($addcode), '<script') !== FALSE || strpos(strtolower($addcode), '<style') !== FALSE || strpos(strtolower($addcode), '<!--') !== FALSE) {
         if (class_exists('PHxParser')) {
             $PHx = new PHxParser();
             $addcode = $PHx->Parse($addcode);
         }
         $addcode = $modx->mergeChunkContent($addcode);
         $addcode = $modx->evalSnippets($addcode);
         $addcode = $modx->mergePlaceholderContent($addcode);
         return $addcode;
     } else {
         $parts = explode($sep, $addcode);
     }
     foreach ($parts as $part) {
         // unmask masked url parameters
         $part = str_replace(array('!q!', '!eq!', '!and!'), array('?', '=', '&'), $part);
         $part = explode($sepmed, trim($part), 2);
         $chunk = $modx->getChunk($part[0]);
         if ($chunk) {
             // part of the parameterchain is a chunkname
             $part[0] = AddHeaderfiles($chunk, $sep, $sepmed, $mediadefault);
             $conditional = strpos(strtolower($part[0]), '<!--') !== FALSE;
             $style = strpos(strtolower($part[0]), '<style') !== FALSE;
             $startup = !(isset($part[1]) && $part[1] == 'end');
             switch (TRUE) {
                 case $conditional:
                     $modx->regClientScript($part[0], TRUE, $startup);
                     break;
                 case $style:
                     $modx->regClientScript($part[0], TRUE, TRUE);
                     break;
                 default:
                     $modx->regClientScript($part[0], FALSE, $startup);
                     break;
             }
         } else {
             // otherwhise it is treated as a filename
             $style = substr(trim($part[0]), -4) == '.css' || strpos($part[0], '/css?') !== FALSE;
             $startup = !(isset($part[1]) && $part[1] == 'end');
             switch (TRUE) {
                 case $style:
                     $modx->regClientCSS($part[0], isset($part[1]) ? $part[1] : $mediadefault);
                     break;
                 default:
                     $modx->regClientScript($part[0], FALSE, $startup);
                     break;
             }
         }
     }
 }
예제 #2
0
 /**
  * Process the current queue with the queue placeholders.
  *
  * @access public
  * @param string $queue The queue name.
  * @param string $outputSeparator Separator between two joined elements.
  * @param boolean $clear Clear queue after process.
  * @return string Processed template.
  */
 public function process($queue = '', $outputSeparator = "\r\n", $clear = TRUE)
 {
     $queue = !empty($queue) ? $queue : $this->queue;
     if ($this->options['phxcheck']) {
         if ($this->options['profile']) {
             $this->profile[$queue]['render'] = isset($this->profile[$queue]['render']) ? $this->profile[$queue]['render'] : 0;
             $start = microtime(TRUE);
         }
         if (!empty($this->templates[$queue])) {
             // Recursive join templates object
             $templates = array();
             foreach ($this->templates[$queue]->templates as $key => $value) {
                 $templates = array_merge($templates, $this->templatesJoinRecursive($value, $key . '.', $outputSeparator));
             }
             $template = implode($outputSeparator, $templates);
             // Process the whole template
             $this->phx->placeholders = array();
             $this->setPHxVariables($this->placeholders[$queue]);
             $output = $this->phx->Parse($template);
             // Unmask uncached elements (will be parsed outside of this)
             if ($this->options['parseLazy']) {
                 $output = str_replace(array('[[¡'), array('[[!'), $output);
             }
         } else {
             $output = '';
         }
         if ($clear) {
             $this->clearPlaceholders($queue);
             $this->clearTemplates($queue);
         }
         if ($this->options['profile']) {
             $end = microtime(TRUE);
             $this->profile[$queue]['render'] += $end - $start;
         }
     } else {
         $output = '<div style="border: 1px solid red;font-weight: bold;margin: 10px;padding: 5px;">';
         $output .= 'Error! This MODx installation is running an older version of the PHx plugin.<br /><br />';
         $output .= 'Please update PHx to version 2.0.0 or higher.<br />OR - Disable the PHx plugin in the MODx Manager. (Elements -> Manage Elements -> Plugins)';
         $output .= '</div>';
     }
     return $output;
 }
예제 #3
0
 /**
  * Generate a listing of a single thumbnail/image for gallery/slideshow display
  */
 function renderSingle()
 {
     global $modx;
     // Retrieve chunks/default templates from disk
     $tpl = $this->config['tpl'] == '' ? file_get_contents($this->config['snippetPath'] . $this->config['type'] . '/tpl.default.txt') : $modx->getChunk($this->config['tpl']);
     $item_tpl = $this->config['itemTpl'] == '' ? file_get_contents($this->config['snippetPath'] . $this->config['type'] . '/tpl.item.default.txt') : $modx->getChunk($this->config['itemTpl']);
     $picSelect = '';
     if ($this->config['picId'] != '*' && !empty($this->config['picId'])) {
         $picSelect = "id = '" . $this->config['picId'] . "'";
     }
     $phx = new PHxParser();
     // Instantiate PHx
     $items = '';
     // Retrieve photos from the database table
     $result = $modx->db->select("*", $modx->getFullTableName($this->galleriesTable), $picSelect);
     if ($modx->db->getRecordCount($result) > 0) {
         while ($row = $modx->fetchRow($result)) {
             $item_phx = new PHxParser();
             foreach ($row as $name => $value) {
                 if ($name == 'filename') {
                     $item_phx->setPHxVariable($name, rawurlencode(trim($value)));
                 } else {
                     $item_phx->setPHxVariable($name, trim($value));
                 }
             }
             $item_phx->setPHxVariable('images_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/');
             $item_phx->setPHxVariable('thumbs_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/thumbs/');
             $item_phx->setPHxVariable('original_dir', $this->config['galleriesUrl'] . $row['content_id'] . '/original/');
             $item_phx->setPHxVariable('plugin_dir', $this->config['snippetUrl'] . $this->config['type'] . '/');
             $items .= $item_phx->Parse($item_tpl);
         }
     }
     $phx->setPHxVariable('items', $items);
     $phx->setPHxVariable('plugin_dir', $this->config['snippetUrl'] . $this->config['type'] . '/');
     return $phx->Parse($tpl);
     // Pass through PHx;
 }
예제 #4
0
if ($action == 78 && $_GET['mode'] == 'treetabs') {
    if (get_permission('edit_chunk', $_GET['id'], $chunk)) {
        include_once "header.inc.php";
        $asset_path = $modx->config['base_path'] . 'assets/plugins/treetabs/actions/chunk.php';
        include_once $asset_path;
        include_once "footer.inc.php";
    }
    exit;
}
if ($action == 10001) {
    if (get_permission('run_chunk', $_GET['id'], $chunk)) {
        include_once MODX_BASE_PATH . 'assets/snippets/ditto/classes/phx.parser.class.inc.php';
        $res = $modx->db->select("name", $modx->getFullTableName('site_htmlsnippets'), "id='" . $_GET['id'] . "'");
        if ($modx->db->getRecordCount($res)) {
            $name = $modx->db->getValue($res);
            $phx = new PHxParser();
            $tpl = $modx->getChunk($name);
            $output = $phx->Parse($tpl);
        }
        echo $output;
    }
    exit;
}
if ($action == 1 && $_GET['f'] == 'nodes' && $_GET['parent'] == $setting_tabs_spec_id) {
    $section = explode('</section>', $chunk);
    foreach ($section as $key => $value) {
        $arr = explode('</name>', $value);
        $elements = explode('</element>', $arr[1]);
        $out = '';
        foreach ($elements as $key2 => $value2) {
            $strings = clear_wites($value2);