예제 #1
0
 public function initMeta($accessDriver)
 {
     parent::initMeta($accessDriver);
     $store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
     if ($store === false) {
         throw new Exception("The 'meta.simple_lock' plugin requires at least one active 'metastore' plugin");
     }
     $this->metaStore = $store;
     $this->metaStore->initMeta($accessDriver);
 }
 public function initMeta($accessDriver)
 {
     parent::initMeta($accessDriver);
     $this->notificationCenter = AJXP_PluginsService::findPluginById("core.notifications");
     $store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
     if ($store === false) {
         throw new Exception("The 'meta.watch' plugin requires at least one active 'metastore' plugin");
     }
     $this->metaStore = $store;
     $this->metaStore->initMeta($accessDriver);
 }
 function init($options)
 {
     parent::init($options);
     $pServ = AJXP_PluginsService::getInstance();
     $aPlugs = $pServ->getActivePlugins();
     $accessPlugs = $pServ->getPluginsByType("access");
     $this->repository = ConfService::getRepository();
     foreach ($accessPlugs as $pId => $plug) {
         if (array_key_exists("access." . $pId, $aPlugs) && $aPlugs["access." . $pId] === true) {
             $this->accessDriver = $plug;
             if (!isset($this->accessDriver->repository)) {
                 $this->accessDriver->init($this->repository);
                 $this->accessDriver->initRepository();
                 $wrapperData = $this->accessDriver->detectStreamWrapper(true);
             } else {
                 $wrapperData = $this->accessDriver->detectStreamWrapper(false);
             }
             $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId();
         }
     }
     $this->metaStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
     if ($this->metaStore !== false) {
         $this->metaStore->initMeta($this->accessDriver);
     }
 }
 public function initMeta($accessDriver)
 {
     parent::initMeta($accessDriver);
     $store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
     if ($store === false) {
         throw new Exception("The 'meta.user' plugin requires at least one active 'metastore' plugin");
     }
     $this->metaStore = $store;
     $this->metaStore->initMeta($accessDriver);
     //$messages = ConfService::getMessages();
     $def = $this->getMetaDefinition();
     foreach ($def as $k => &$d) {
         if (isset($this->fieldsAdditionalData[$k])) {
             $d["data"] = $this->fieldsAdditionalData[$k];
         }
     }
     $this->exposeConfigInManifest("meta_definitions", json_encode($def));
     if (!isset($this->options["meta_visibility"])) {
         $visibilities = array("visible");
     } else {
         $visibilities = explode(",", $this->options["meta_visibility"]);
     }
     $editButton = '';
     $u = AuthService::getLoggedUser();
     if ($u != null && $u->canWrite($this->accessDriver->repository->getId())) {
         $editButton = '<span class="icon-edit" data-ajxpAction="edit_user_meta" title="AJXP_MESSAGE[meta.user.1]"></span><span class="user_meta_change" style="display: none;" data-ajxpAction="edit_user_meta" title="AJXP_MESSAGE[meta.user.1]">AJXP_MESSAGE[457]</span>';
     }
     $cdataHead = '<div>
                     <div class="panelHeader infoPanelGroup" colspan="2">' . $editButton . 'AJXP_MESSAGE[meta.user.1]</div>
                  ';
     $cdataFoot = '</div>';
     $cdataParts = "";
     $selection = $this->getXPath()->query('registry_contributions/client_configs/component_config[@className="FilesList"]/columns');
     $contrib = $selection->item(0);
     $even = false;
     $searchables = array();
     $searchablesRenderers = array();
     $index = 0;
     $fieldType = "text";
     foreach ($def as $key => $data) {
         $label = $data["label"];
         $fieldType = $data["type"];
         if (isset($visibilities[$index])) {
             $lastVisibility = $visibilities[$index];
         }
         $index++;
         $col = $this->manifestDoc->createElement("additional_column");
         $col->setAttribute("messageString", $label);
         $col->setAttribute("attributeName", $key);
         $col->setAttribute("sortType", "String");
         if (isset($lastVisibility)) {
             $col->setAttribute("defaultVisibilty", $lastVisibility);
         }
         switch ($fieldType) {
             case "stars_rate":
                 $col->setAttribute("modifier", "MetaCellRenderer.prototype.starsRateFilter");
                 $col->setAttribute("sortType", "CellSorterValue");
                 $searchables[$key] = $label;
                 $searchablesRenderers[$key] = "MetaCellRenderer.prototype.formPanelStars";
                 break;
             case "css_label":
                 $col->setAttribute("modifier", "MetaCellRenderer.prototype.cssLabelsFilter");
                 $col->setAttribute("sortType", "CellSorterValue");
                 $searchables[$key] = $label;
                 $searchablesRenderers[$key] = "MetaCellRenderer.prototype.formPanelCssLabels";
                 break;
             case "textarea":
                 $searchables[$key] = $label;
                 break;
             case "string":
                 $searchables[$key] = $label;
                 break;
             case "choice":
                 $searchables[$key] = $label;
                 $col->setAttribute("modifier", "MetaCellRenderer.prototype.selectorsFilter");
                 $col->setAttribute("sortType", "CellSorterValue");
                 $col->setAttribute("metaAdditional", $this->fieldsAdditionalData[$key]);
                 $searchablesRenderers[$key] = "MetaCellRenderer.prototype.formPanelSelectorFilter";
                 break;
             case "tags":
                 $searchables[$key] = $label;
                 $searchablesRenderers[$key] = "MetaCellRenderer.prototype.formPanelTags";
                 break;
             default:
                 break;
         }
         $contrib->appendChild($col);
         $trClass = $even ? " class=\"even infoPanelRow\"" : " class=\"infoPanelRow\"";
         $even = !$even;
         $cdataParts .= '<div' . $trClass . '><div class="infoPanelLabel">' . $label . '</div><div class="infoPanelValue" data-metaType="' . $fieldType . '" id="ip_' . $key . '">#{' . $key . '}</div></div>';
     }
     $selection = $this->getXPath()->query('registry_contributions/client_configs/component_config[@className="InfoPanel"]/infoPanelExtension');
     $contrib = $selection->item(0);
     $contrib->setAttribute("attributes", implode(",", array_keys($def)));
     if (!empty($this->fieldsAdditionalData)) {
         $contrib->setAttribute("metaAdditional", json_encode($this->fieldsAdditionalData));
     }
     $contrib->setAttribute("modifier", "MetaCellRenderer.prototype.infoPanelModifier");
     $htmlSel = $this->getXPath()->query('html', $contrib);
     $html = $htmlSel->item(0);
     $cdata = $this->manifestDoc->createCDATASection($cdataHead . $cdataParts . $cdataFoot);
     $html->appendChild($cdata);
     $selection = $this->getXPath()->query('registry_contributions/client_configs/template_part[@ajxpClass="SearchEngine"]');
     foreach ($selection as $tag) {
         $v = $tag->attributes->getNamedItem("ajxpOptions")->nodeValue;
         $metaV = count($searchables) ? '"metaColumns":' . json_encode($searchables) : "";
         if (count($searchablesRenderers)) {
             $metaV .= ',"metaColumnsRenderers":' . json_encode($searchablesRenderers);
         }
         if (!empty($v) && trim($v) != "{}" && !empty($metaV)) {
             $v = str_replace("}", ", " . $metaV . "}", $v);
         } else {
             $v = "{" . $metaV . "}";
         }
         $tag->setAttribute("ajxpOptions", $v);
     }
     parent::init($this->options);
 }
    public function initMeta($accessDriver)
    {
        $this->accessDriver = $accessDriver;
        $store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
        if ($store === false) {
            throw new Exception("The 'meta.user' plugin requires at least one active 'metastore' plugin");
        }
        $this->metaStore = $store;
        $this->metaStore->initMeta($accessDriver);
        //$messages = ConfService::getMessages();
        $def = $this->getMetaDefinition();
        if (!isset($this->options["meta_visibility"])) {
            $visibilities = array("visible");
        } else {
            $visibilities = explode(",", $this->options["meta_visibility"]);
        }
        $cdataHead = '<div>
						<div class="panelHeader infoPanelGroup" colspan="2">AJXP_MESSAGE[meta.user.1]</div>
						<table class="infoPanelTable" cellspacing="0" border="0" cellpadding="0">';
        $cdataFoot = '</table></div>';
        $cdataParts = "";
        $selection = $this->xPath->query('registry_contributions/client_configs/component_config[@className="FilesList"]/columns');
        $contrib = $selection->item(0);
        $even = false;
        $searchables = array();
        $index = 0;
        $fieldType = "text";
        foreach ($def as $key => $label) {
            if (isset($visibilities[$index])) {
                $lastVisibility = $visibilities[$index];
            }
            $index++;
            $col = $this->manifestDoc->createElement("additional_column");
            $col->setAttribute("messageString", $label);
            $col->setAttribute("attributeName", $key);
            $col->setAttribute("sortType", "String");
            if (isset($lastVisibility)) {
                $col->setAttribute("defaultVisibilty", $lastVisibility);
            }
            if ($key == "stars_rate") {
                $col->setAttribute("modifier", "MetaCellRenderer.prototype.starsRateFilter");
                $col->setAttribute("sortType", "CellSorterValue");
                $fieldType = "stars_rate";
            } else {
                if ($key == "css_label") {
                    $col->setAttribute("modifier", "MetaCellRenderer.prototype.cssLabelsFilter");
                    $col->setAttribute("sortType", "CellSorterValue");
                    $fieldType = "css_label";
                } else {
                    if (substr($key, 0, 5) == "area_") {
                        $searchables[$key] = $label;
                        $fieldType = "textarea";
                    } else {
                        $searchables[$key] = $label;
                        $fieldType = "text";
                    }
                }
            }
            $contrib->appendChild($col);
            $trClass = $even ? " class=\"even\"" : "";
            $even = !$even;
            $cdataParts .= '<tr' . $trClass . '><td class="infoPanelLabel">' . $label . '</td><td class="infoPanelValue" data-metaType="' . $fieldType . '" id="ip_' . $key . '">#{' . $key . '}</td></tr>';
        }
        $selection = $this->xPath->query('registry_contributions/client_configs/component_config[@className="InfoPanel"]/infoPanelExtension');
        $contrib = $selection->item(0);
        $contrib->setAttribute("attributes", implode(",", array_keys($def)));
        if (isset($def["stars_rate"]) || isset($def["css_label"])) {
            $contrib->setAttribute("modifier", "MetaCellRenderer.prototype.infoPanelModifier");
        }
        $htmlSel = $this->xPath->query('html', $contrib);
        $html = $htmlSel->item(0);
        $cdata = $this->manifestDoc->createCDATASection($cdataHead . $cdataParts . $cdataFoot);
        $html->appendChild($cdata);
        $selection = $this->xPath->query('registry_contributions/client_configs/template_part[@ajxpClass="SearchEngine"]');
        $tag = $selection->item(0);
        $tag->setAttribute("ajxpOptions", json_encode(count($searchables) ? array("metaColumns" => $searchables) : array()));
        parent::init($this->options);
    }