/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { parent::__construct($modx, $config); $fqn = $modx->getOption('twiggy_class', null, 'twiggy.twiggy', true); $path = $modx->getOption('twiggy_class_path', null, MODX_CORE_PATH . 'components/twiggy/model/', true); if ($twiggyClass = $modx->loadClass($fqn, $path, false, true)) { $this->twiggy = new $twiggyClass($modx, $this->config); } }
/** * Recursive template of branch of menu * * @param array $row * * @return mixed|string */ public function templateBranch($row = array()) { $children = ''; $row['level'] = $this->level; if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) { $idx = 1; $this->level++; $count = count($row['children']); foreach ($row['children'] as $v) { $v['idx'] = $idx++; $v['last'] = (int) $v['idx'] == $count; $children .= $this->templateBranch($v); } $this->level--; $row['children'] = $count; } else { $row['children'] = isset($row['children']) ? count($row['children']) : 0; } if (!empty($this->pdoTools->config['countChildren'])) { if ($ids = $this->modx->getChildIds($row['id'])) { $tstart = microtime(true); $count = $this->modx->getCount('modResource', array('id:IN' => $ids, 'published' => true, 'deleted' => false)); $this->modx->queryTime += microtime(true) - $tstart; $this->modx->executedQueries++; $this->pdoTools->addTime('Got the number of active children for resource "' . $row['id'] . '": ' . $count); } else { $count = 0; } $row['children'] = $count; } if (!empty($children)) { $pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass'], 'level' => $this->level)); $row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls); } else { $row['wrapper'] = ''; } if (empty($row['menutitle']) && !empty($row['pagetitle'])) { $row['menutitle'] = $row['pagetitle']; } $classes = $this->getClasses($row); if (!empty($classes)) { $row['classNames'] = $row['classnames'] = $classes; $row['classes'] = ' class="' . $classes . '"'; } else { $row['classNames'] = $row['classnames'] = $row['classes'] = ''; } if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') { $row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), '', '', $this->pdoTools->config['scheme']) : $row['content']; } else { $row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']); } $row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : ''; $tpl = $this->getTpl($row); $row = $this->addWayFinderPlaceholders($row); return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']); }
public function process() { $result = array(); $queryAll = array('class' => $this->classKey, 'where' => $this->modx->toJSON(['key' => 'tags']), 'select' => $this->modx->toJSON(['value' => 'msProductOption.value']), 'groupby' => 'msProductOption.value', 'limit' => 0, 'fastMode' => true, 'sortby' => 'msProductOption.value', 'sortdir' => 'ASC', 'return' => 'data'); $this->pdoFetch->setConfig($queryAll); $tagsAll = $this->pdoFetch->run(); $tagsAll = array_map(function ($tag) { return array('id' => $tag['value'], 'text' => $tag['value']); }, $tagsAll); $result['all'] = $tagsAll; if ($this->pid !== '0') { $queryProduct = array('class' => $this->classKey, 'where' => $this->modx->toJSON(['product_id' => $this->pid, 'key' => 'tags']), 'select' => $this->modx->toJSON(['value' => 'msProductOption.value']), 'groupby' => 'msProductOption.value', 'limit' => 0, 'fastMode' => true, 'sortby' => 'msProductOption.value', 'sortdir' => 'ASC', 'return' => 'data'); $this->pdoFetch->setConfig($queryProduct); $tagsProduct = $this->pdoFetch->run(); $tagsProduct = array_map(function ($tag) { return $tag['value']; }, $tagsProduct); $result['product'] = $tagsProduct; } return $this->success('', $result); }
public function process() { $result = array(); $result['all'] = array(); $config = array('hideUnsearchable' => '1', 'parents' => $this->config['parents'], 'resources' => $this->config['resources'], 'includeTVs' => $this->config['parentsIncludeTVs'], 'sortby' => $this->config['parentsSortby'], 'sortdir' => $this->config['parentsSortdir'], 'return' => 'data'); $msCategories = $this->pdoFetch->getCollection($this->classKey, array('class_key' => $this->classKey), $config); $result['all'] = array_map(function ($msCategory) { return array('id' => $msCategory['id'], 'text' => $this->pdoFetch->getChunk($this->config['tplSectionRow'], $msCategory, false)); }, $msCategories); if ($this->pid !== '0') { $categoryMembers = array_map(function ($msMember) { return $msMember['category_id']; }, $this->pdoFetch->getCollection('msCategoryMember', array('product_id' => $this->pid))); $msCategoriesIds = array_map(function ($msCategory) { return $msCategory['id']; }, $msCategories); $result['product'] = array_values(array_filter($categoryMembers, function ($categoryMember) use($msCategoriesIds) { if (in_array($categoryMember, $msCategoriesIds)) { return true; } })); } return $this->success('', $result); }
/** * Recursive template of branch of menu * * @param array $row * * @return mixed|string */ public function templateBranch($row = array()) { $children = ''; $row['level'] = $this->level; if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) { $idx = 1; $this->level++; $count = count($row['children']); foreach ($row['children'] as $v) { $v['idx'] = $idx++; $v['last'] = (int) $v['idx'] == $count; $children .= $this->templateBranch($v); } $this->level--; $row['children'] = $count; } else { $row['children'] = 0; } if (!empty($children)) { $pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass'])); $row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls); } else { $row['wrapper'] = ''; } if (empty($row['menutitle']) && !empty($row['pagetitle'])) { $row['menutitle'] = $row['pagetitle']; } $classes = $this->getClasses($row); if (!empty($classes)) { $row['classNames'] = $row['classnames'] = $classes; $row['classes'] = ' class="' . $classes . '"'; } else { $row['classNames'] = $row['classnames'] = $row['classes'] = ''; } if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') { $row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), $row['context_key'], '', $this->pdoTools->config['scheme']) : $row['content']; } else { $row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']); } $row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : ''; $tpl = $this->getTpl($row); $row = $this->addWayFinderPlaceholders($row); return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']); }
<?php /* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $cart = $miniShop2->cart->get(); $status = $miniShop2->cart->status(); if (!empty($_GET['msorder'])) { return ''; } elseif (empty($status['total_count'])) { return !empty($tplEmpty) ? $pdoFetch->getChunk($tplEmpty) : ''; } // Include Thumbnails $thumbsLeftJoin = ''; $thumbsSelect = array(); if (!empty($includeThumbs)) { $thumbs = array_map('trim', explode(',', $includeThumbs)); if (!empty($thumbs[0])) { foreach ($thumbs as $thumb) { $thumbsLeftJoin .= ',{"class":"msProductFile","alias":"' . $thumb . '","on":"' . $thumb . '.product_id = msProduct.id AND ' . $thumb . '.parent != 0 AND ' . $thumb . '.path LIKE \'%/' . $thumb . '/\'"}'; $thumbsSelect[] = ' "' . $thumb . '":"' . $thumb . '.url as ' . $thumb . '" '; } $pdoFetch->addTime('Included list of thumbnails: <b>' . implode(', ', $thumbs) . '</b>.'); } }
<?php /* @var array $scriptProperties */ /* @var ms2Gallery $ms2Gallery */ $ms2Gallery = $modx->getService('ms2gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/'); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $extensionsDir = $modx->getOption('extensionsDir', $scriptProperties, 'components/ms2gallery/img/mgr/extensions/', true); // Register styles and scripts on frontend $config = $ms2Gallery->makePlaceholders($ms2Gallery->config); $css = $modx->getOption('frontend_css', $scriptProperties, 'frontend_css'); if (!empty($css) && preg_match('/\\.css/i', $css)) { $modx->regClientCSS(str_replace($config['pl'], $config['vl'], $css)); } $js = $modx->getOption('frontend_js', $scriptProperties, 'frontend_js'); if (!empty($js) && preg_match('/\\.js/i', $js)) { $modx->regClientScript(str_replace($config['pl'], $config['vl'], $js)); } if (empty($outputSeparator)) { $outputSeparator = "\n"; } if (empty($tagsSeparator)) { $tagsSeparator = ','; } $where = array('File.parent' => 0); // Define where parameters if ($scriptProperties['parents'] == '' && empty($scriptProperties['resources'])) { $resources = !empty($resource) ? $resource : $modx->resource->get('id');
<?php /* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $pdoFetch->addTime('pdoTools loaded.'); if (!empty($_GET['msorder'])) { if ($order = $modx->getObject('msOrder', $_GET['msorder'])) { if (!empty($_SESSION['minishop2']['orders']) && in_array($_GET['msorder'], $_SESSION['minishop2']['orders']) || $order->get('user_id') == $modx->user->id || $modx->context->key == 'mgr') { if (empty($tplSuccess)) { $tplSuccess = 'tpl.msOrder.success'; } return $pdoFetch->getChunk($tplSuccess, array('id' => $_GET['msorder'])); } } } $cart = $miniShop2->cart->get(); $status = $miniShop2->cart->status(); $order = $miniShop2->order->get(); if (empty($status['total_count'])) { return !empty($tplEmpty) ? $pdoFetch->getChunk($tplEmpty) : ''; } $deliveryColumns = $modx->getSelectColumns('msDelivery', 'msDelivery', 'delivery_'); $paymentColumns = $modx->getSelectColumns('msPayment', 'msPayment', 'payment_'); // Default parameters
/* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); // You can set modResource instead of msProduct if (empty($class)) { $scriptProperties['class'] = 'msProduct'; } if (isset($parents) && $parents === '') { $scriptProperties['parents'] = $modx->resource->id; } /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); // Start building "Where" expression $where = array('class_key' => 'msProduct'); if (empty($showZeroPrice)) { $where['Data.price:>'] = 0; } // Joining tables $leftJoin = array(array('class' => 'msProductData', 'alias' => 'Data', 'on' => '`' . $class . '`.`id`=`Data`.`id`'), array('class' => 'msVendor', 'alias' => 'Vendor', 'on' => '`Data`.`vendor`=`Vendor`.`id`')); $innerJoin = array(); // Include Thumbnails $thumbsSelect = array(); if (!empty($includeThumbs)) { $thumbs = array_map('trim', explode(',', $includeThumbs)); if (!empty($thumbs[0])) { foreach ($thumbs as $thumb) { $leftJoin[] = array('class' => 'msProductFile', 'alias' => $thumb, 'on' => "`{$thumb}`.`product_id` = `{$class}`.`id` AND `{$thumb}`.`parent` != 0 AND `{$thumb}`.`path` LIKE '%/{$thumb}/'");
<?php $output = ""; //working only with auth users if ($modx->user->isAuthenticated($modx->context->key)) { if ($modx->user->active || !$modx->user->Profile->blocked) { $ePochta = $modx->getService('epochta', 'ePochta', $modx->getOption('epochta_core_path', null, $modx->getOption('core_path') . 'components/epochta/') . 'model/epochta/', $scriptProperties); $ePochta->initialize($modx->context->key, $scriptProperties); if (!$ePochta instanceof ePochta) { return ''; } /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $pdoFetch->addTime('pdoTools loaded.'); /* prepare settings */ if (!isset($tplCheck)) { $tplCheck = 'tpl.epPhone.check'; } if (!isset($tplExists)) { $tplExists = 'tpl.epPhone.exists'; } /* If user already have phone nothing to do */ $profile = $modx->user->getOne('Profile'); $userPhone = $profile->get('mobilephone'); if (!empty($userPhone)) { $output = $pdoFetch->getChunk($tplExists, array('mobilephone' => $userPhone)); } else { $output = $pdoFetch->getChunk($tplCheck);
<?php /* @var array $scriptProperties */ /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); if (empty($product) && !empty($input)) { $product = $input; } if (empty($selected)) { $selected = ''; } if (empty($outputSeparator)) { $outputSeparator = "\n"; } if ((empty($name) || $name == 'id') && !empty($options)) { $name = $options; } $output = ''; $product = !empty($product) ? $modx->getObject('msProduct', $product) : ($product = $modx->resource); if (!$product instanceof msProduct) { $output = 'This resource is not instance of msProduct class.'; } elseif (!empty($name) && ($options = $product->get($name))) { if (!is_array($options) || $options[0] == '') { $output = !empty($tplEmpty) ? $pdoFetch->getChunk($tplEmpty, $scriptProperties) : ''; } else { $rows = array(); foreach ($options as $value) { $pls = array('value' => $value, 'selected' => $value == $selected ? 'selected' : '');
<?php /** @var array $scriptProperties */ /** @var mSearch2 $mSearch2 */ if (!$modx->loadClass('msearch2', MODX_CORE_PATH . 'components/msearch2/model/msearch2/', false, true)) { return false; } $mSearch2 = new mSearch2($modx, $scriptProperties); /** @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $pdoFetch->addTime('pdoTools loaded.'); if (empty($queryVar)) { $queryVar = 'query'; } if (empty($parentsVar)) { $parentsVar = 'parents'; } if (empty($minQuery)) { $minQuery = $modx->getOption('index_min_words_length', null, 3, true); } if ($depth == '') { $depth = 10; } if (empty($htagOpen)) { $htagOpen = '<b>'; } if (empty($htagClose)) { $htagClose = '</b>';
<?php /* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $extensionsDir = $modx->getOption('extensionsDir', $scriptProperties, 'components/minishop2/img/mgr/extensions/', true); /** @var msProduct $product */ $product = !empty($product) && $product != $modx->resource->id ? $modx->getObject('msProduct', $product) : $modx->resource; if (!$product || !$product instanceof msProduct) { return 'This resource is not instance of msProduct class.'; } /** @var msProductData $data */ $resolution = array(); if ($data = $product->getOne('Data')) { $data->initializeMediaSource(); $properties = $data->mediaSource->getProperties(); if (isset($properties['thumbnails']['value'])) { $fileTypes = $modx->fromJSON($properties['thumbnails']['value']); foreach ($fileTypes as $v) { $resolution[] = $v['w'] . 'x' . $v['h']; } } } if (empty($limit)) { $limit = 100;
/** * @param modX $modx * @param array $config */ public function __construct(modX &$modx, $config = array()) { return parent::__construct($modx, $config); }
<?php /** @var array $scriptProperties */ /* @var pdoFetch $pdoFetch */ if (!$modx->getService('pdoFetch')) { return 'You need to install pdoTools to use this snippet!'; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $pdoFetch->addTime('pdoTools loaded'); $modx->lexicon->load('bannery:default'); $modx->addPackage('bannery', MODX_CORE_PATH . 'components/bannery/model/'); if (!empty($tplOuter)) { $tplWrapper = $tplOuter; } if (empty($outputSeparator)) { $outputSeparator = "\n"; } $class = 'byAd'; // Adding extra parameters into special place so we can put them in results /** @var modSnippet $snippet */ $additionalPlaceholders = array(); if ($snippet = $modx->getObject('modSnippet', array('name' => 'BannerY'))) { $properties = unserialize($snippet->properties); foreach ($scriptProperties as $k => $v) { if (!isset($properties[$k])) { $additionalPlaceholders[$k] = $v; } } } // --- $date = date('Y-m-d H:i:s');
<?php if (empty($id)) { return $modx->lexicon('ms2_err_order_nf'); } /* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); /* @var msOrder $order */ if (!($order = $modx->getObject('msOrder', $id))) { return $modx->lexicon('ms2_err_order_nf'); } if ((empty($_SESSION['minishop2']['orders']) || !in_array($id, $_SESSION['minishop2']['orders'])) && $order->get('user_id') != $modx->user->id && $modx->context->key != 'mgr') { return !empty($tplEmpty) ? $pdoFetch->getChunk($tplEmpty) : ''; } $pls_order = $order->toArray(); $pls_user = $order->getOne('User')->getOne('Profile')->toArray('user.'); $pls_address = $order->getOne('Address')->toArray('address.'); $pls_delivery = $order->getOne('Delivery')->toArray('delivery.'); $pls_payment = $order->getOne('Payment')->toArray('payment.'); $outer = array_merge($pls_order, $pls_user, $pls_address, $pls_delivery, $pls_payment); $outer['goods'] = ''; $outer['cart_count'] = 0; $outer['cost'] = $miniShop2->formatPrice($outer['cost']); $outer['cart_cost'] = $miniShop2->formatPrice($outer['cart_cost']);
<?php /* @var array $scriptProperties */ /* @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('minishop2'); $miniShop2->initialize($modx->context->key); /* @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $output = ''; if (empty($product) && !empty($input)) { $product = $input; } if (empty($outputSeparator)) { $outputSeparator = "\n"; } $options = explode(",", $modx->getOption('options', $scriptProperties, '')); $product = !empty($product) ? $modx->getObject('msProduct', $product) : ($product = $modx->resource); if (!$product instanceof msProduct) { $output = 'This resource is not instance of msProduct class.'; } $optionKeys = $product->getOptionKeys(); $productData = $product->toArray(); $ignoreOptions = explode(',', trim($modx->getOption('ignoreOptions', $scriptProperties, ''))); if (!empty($groups)) { $groups = explode(',', trim($groups)); $groups = array_map('trim', $groups); } else { if ($groups === '0') {
<?php /** @var array $scriptProperties */ /** @var mSearch2 $mSearch2 */ if (!$modx->loadClass('msearch2', MODX_CORE_PATH . 'components/msearch2/model/msearch2/', false, true)) { return false; } $mSearch2 = new mSearch2($modx, $scriptProperties); $mSearch2->initialize($modx->context->key); /** @var pdoFetch $pdoFetch */ if (!$modx->loadClass('pdofetch', MODX_CORE_PATH . 'components/pdotools/model/pdotools/', false, true)) { return false; } $pdoFetch = new pdoFetch($modx, $scriptProperties); $pdoFetch->addTime('pdoTools loaded.'); $_SESSION['mFilter2'][$modx->resource->id] = array(); if (empty($queryVar)) { $queryVar = 'query'; } if (empty($parentsVar)) { $parentsVar = 'parents'; } if (empty($minQuery)) { $minQuery = $modx->getOption('index_min_words_length', null, 3, true); } if ($depth == '') { $depth = 10; } if (empty($classActive)) { $classActive = 'active'; }