public function view($term, $pageID)
 {
     //require_once  'JsonClientUtil.php';
     require_once 'ServiceUtil.php';
     require_once 'Config.php';
     $myConfig = new Config();
     $myConfig->loadJsonConfig($data);
     $util = new ServiceUtil();
     $data['test'] = NULL;
     $term = str_replace("_", "%20", $term);
     //$term = str_replace("/", "%2F", $term);
     $startPoint = ($pageID - 1) * 20;
     $result = $util->expandTerm($term);
     $terms = $util->parseExpandedTerm($result, $term);
     //$litResult = searchLiteratureByYearUsingSolr($terms,$startPoint,20,"*",$year);
     $litResult = $util->searchLatestLiterature($terms, $startPoint, 20, "*", "*");
     $data['publications'] = $litResult;
     $data['term'] = $term;
     $data['pageID'] = $pageID;
     $data['page_title'] = "Literature:" . str_replace("%20", " ", $term);
     $data['enable_config'] = true;
     $this->load->view('templates/header2', $data);
     $this->load->view('pages/latestPublicationDisplay', $data);
     $this->load->view('templates/footer2', $data);
 }
 public function summary($page)
 {
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     require_once 'Config.php';
     $myConfig = new Config();
     $myConfig->loadJsonConfig($data);
     $pageName = NULL;
     $termObj = NULL;
     $pageName = $page;
     $pos = strpos($pageName, ":");
     //echo "----pos:".$pos;
     if ($pos == false) {
         $pageName = str_replace("_", "%20", $page);
         $pageName = str_replace(",", "%2c", $pageName);
         $data["page"] = $page;
     }
     $isNifID = false;
     $originalPageName = "";
     if ($pos != false) {
         $termObj[0] = $util->getObjByCurie($pageName);
         #echo "\n-------Willy----!is_null(termObj):".!is_null($termObj)."\n";
         if (!is_null($termObj) && !is_null($termObj[0])) {
             $data['curie'] = $termObj[0]->curie;
             if (count($termObj[0]->labels) > 0) {
                 $data['pageName'] = $termObj[0]->labels[0];
                 $pageName = $data['pageName'];
                 $originalPageName = $pageName;
                 $pageName = str_replace(" ", "%20", $pageName);
                 $pageName = str_replace(",", "%2c", $pageName);
                 $data['pageName'] = $pageName;
                 $isNifID = true;
             } else {
                 $data['pageName'] = $pageName;
             }
         } else {
             $data['pageName'] = $pageName;
             $termObj = getTerm($pageName);
         }
     }
     $pageName = str_replace(str_split('_'), '%20', $pageName);
     $pageName = str_replace(str_split(','), '%2c', $pageName);
     $pageName = str_replace(str_split('/'), '%2f', $pageName);
     $data['pageName'] = $pageName;
     $data['page_title'] = $pageName;
     $data['enable_config'] = true;
     $stitle = "";
     if (!$isNifID) {
         $stitle = ucfirst($page);
         $stitle = str_replace("_", " ", $stitle);
         $data['title'] = $stitle;
     } else {
         $stitle = $originalPageName;
         $data['title'] = $stitle;
     }
     $this->handleDataSpace($data, $pageName);
     $this->load->view('api/view_summary', $data);
 }
 public function handleLiterature(&$data, $searchName)
 {
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     $result = $util->expandTerm($searchName);
     $terms = $util->parseExpandedTerm($result, $searchName);
     $litResult = $util->searchLiteratureByYearUsingSolr($terms, 0, 25000000, "year", "*");
     $litMap = $util->processLiteratureObj($litResult);
     //var_dump($litMap);
     $data['litMap'] = $litMap;
     $count = count($litMap);
     $data['count'] = $count;
     $data['page_title'] = "Literature:" . str_replace("%20", " ", $searchName);
     $data['enable_config'] = true;
 }
示例#4
0
 /**
  *  Returns the page render time.
  *
  * @return number
  */
 public function getTimeDiff()
 {
     $start = \ServiceUtil::getManager()->getParameter('debug.toolbar.panel.rendertime.start');
     $end = microtime(true);
     $diff = $end - $start;
     return $diff;
 }
示例#5
0
 /**
  * Remove a directory from zikula's local cache directory.
  *
  * @param string $dir      The name of the directory to remove.
  * @param bool   $absolute Whether to process the passed dir as an absolute path or not.
  *
  * @return boolean true if successful, false otherwise.
  */
 public static function removeLocalDir($dir, $absolute = false)
 {
     $sm = ServiceUtil::getManager();
     $base = $sm['kernel.cache_dir'] . '/ztemp';
     $path = $base . '/' . $dir;
     return FileUtil::deldir($path, $absolute);
 }
示例#6
0
 /**
 *
 This method is for getting a repository for movies
 *
 */
 public static function getMovieRepository()
 {
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repository = $entityManager->getRepository('MUVideo_Entity_Movie');
     return $repository;
 }
示例#7
0
 /**
  * Loads the data.
  *
  * @param array $data Data array with parameters.
  */
 public function loadData(&$data)
 {
     $serviceManager = ServiceUtil::getManager();
     $controllerHelper = new MUVideo_Util_Controller($serviceManager);
     $utilArgs = array('name' => 'detail');
     if (!isset($data['objectType']) || !in_array($data['objectType'], $controllerHelper->getObjectTypes('contentType', $utilArgs))) {
         $data['objectType'] = $controllerHelper->getDefaultObjectType('contentType', $utilArgs);
     }
     $this->objectType = $data['objectType'];
     if (!isset($data['id'])) {
         $data['id'] = null;
     }
     if (!isset($data['moviewidth'])) {
         $data['moviewidth'] = 400;
     }
     $this->moviewidth = $data['moviewidth'];
     if (!isset($data['movieheight'])) {
         $data['movieheight'] = 300;
     }
     $this->movieheight = $data['movieheight'];
     if (!isset($data['displayMode'])) {
         $data['displayMode'] = 'embed';
     }
     $this->id = $data['id'];
     $this->displayMode = $data['displayMode'];
 }
 protected function bootstrap($disableSessions = true, $loadZikulaCore = true, $fakeRequest = true)
 {
     define('_ZINSTALLVER', \Zikula_Core::VERSION_NUM);
     $kernel = $this->getContainer()->get('kernel');
     $loader = (require $kernel->getRootDir() . '/autoload.php');
     \ZLoader::register($loader);
     if ($loadZikulaCore && !$this->getContainer()->has('zikula')) {
         $core = new Zikula_Core();
         $core->setKernel($kernel);
         $core->boot();
         foreach ($GLOBALS['ZConfig'] as $config) {
             $core->getContainer()->loadArguments($config);
         }
         $GLOBALS['ZConfig']['System']['temp'] = $core->getContainer()->getParameter('temp_dir');
         $GLOBALS['ZConfig']['System']['datadir'] = $core->getContainer()->getParameter('datadir');
         $GLOBALS['ZConfig']['System']['system.chmod_dir'] = $core->getContainer()->getParameter('system.chmod_dir');
         \ServiceUtil::getManager($core);
         \EventUtil::getManager($core);
     }
     if ($disableSessions) {
         // Disable sessions.
         $this->getContainer()->set('session.storage', new MockArraySessionStorage());
         $this->getContainer()->set('session.handler', new NullSessionHandler());
     }
     if ($fakeRequest) {
         // Fake request
         $request = Request::create('http://localhost/install');
         $this->getContainer()->set('request', $request);
     }
 }
示例#9
0
 /**
  * Constructor.
  *
  * @param integer             $objectId  Identifier of treated object.
  * @param integer             $areaId    Name of hook area.
  * @param string              $module    Name of the owning module.
  * @param string              $urlString **deprecated**
  * @param Zikula_ModUrl $urlObject Object carrying url arguments.
  */
 function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null)
 {
     // call base constructor to store arguments in member vars
     parent::__construct($objectId, $areaId, $module, $urlString, $urlObject);
     // derive object type from url object
     $urlArgs = $urlObject->getArgs();
     $objectType = isset($urlArgs['ot']) ? $urlArgs['ot'] : 'review';
     $component = $module . ':' . ucwords($objectType) . ':';
     $perm = SecurityUtil::checkPermission($component, $objectId . '::', ACCESS_READ);
     if (!$perm) {
         return;
     }
     $entityClass = $module . '_Entity_' . ucwords($objectType);
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repository = $entityManager->getRepository($entityClass);
     $useJoins = false;
     /** TODO support composite identifiers properly at this point */
     $entity = $repository->selectById($objectId, $useJoins);
     if ($entity === false || !is_array($entity) && !is_object($entity)) {
         return;
     }
     $this->setObjectTitle($entity->getTitleFromDisplayPattern());
     $dateFieldName = $repository->getStartDateFieldName();
     if ($dateFieldName != '') {
         $this->setObjectDate($entity[$dateFieldName]);
     } else {
         $this->setObjectDate('');
     }
     if (method_exists($entity, 'getCreatedUserId')) {
         $this->setObjectAuthor(UserUtil::getVar('uname', $entity['createdUserId']));
     } else {
         $this->setObjectAuthor('');
     }
 }
示例#10
0
 /**
  * Post constructor hook.
  *
  * @return void
  */
 public function setup()
 {
     $this->view = \Zikula_View::getInstance(self::MODULENAME, false);
     // set caching off
     $this->_em = \ServiceUtil::get('doctrine.entitymanager');
     $this->domain = \ZLanguage::getModuleDomain(self::MODULENAME);
 }
示例#11
0
 /**
  * The main procedure for managing stylesheets and javascript files.
  *
  * Gets demanded files from PageUtil variables, check them and resolve dependencies.
  * Returns an array with two arrays, containing list of js and css files
  * ready to embedded in the HTML HEAD.
  *
  * @param bool   $combine   Should files be combined.
  * @param string $cache_dir Path to cache directory.
  *
  * @return array Array with two array containing the files to be embedded into HTML HEAD
  */
 public static function prepareJCSS($combine = false, $cache_dir = null)
 {
     $combine = $combine && is_writable($cache_dir);
     $jcss = array();
     // get page vars
     $javascripts = PageUtil::getVar('javascript');
     $stylesheets = PageUtil::getVar('stylesheet');
     $javascripts = self::prepareJavascripts($javascripts, $combine);
     // update stylesheets as there might be some additions for js
     $stylesheets = array_merge((array) $stylesheets, (array) PageUtil::getVar('stylesheet'));
     $stylesheets = self::prepareStylesheets($stylesheets, $combine);
     if ($combine) {
         $javascripts = (array) self::save($javascripts, 'js', $cache_dir);
         $stylesheets = (array) self::save($stylesheets, 'css', $cache_dir);
     }
     /* @var \Symfony\Component\HttpFoundation\Request $request */
     $request = ServiceUtil::getManager()->get('request');
     $basePath = $request->getBasePath();
     foreach ($stylesheets as $key => $value) {
         $stylesheets[$key] = $basePath . '/' . $value;
     }
     foreach ($javascripts as $key => $value) {
         $javascripts[$key] = $basePath . '/' . $value;
     }
     $jcss = array('stylesheets' => $stylesheets, 'javascripts' => $javascripts);
     // some core js libs require js gettext - ensure that it will be loaded
     $jsgettext = self::getJSGettext();
     if (!empty($jsgettext)) {
         array_unshift($jcss['javascripts'], $jsgettext);
     }
     return $jcss;
 }
示例#12
0
 /**
  * Sync the filesystem scan and the Bundles table
  * This is a 'dumb' scan - there is no state management here
  *      state management occurs in the module and theme management
  *      and is checked in Bundle/Bootstrap
  *
  * @param $array array of extensions
  *          obtained from filesystem scan
  *          key is bundle name and value an instance of \Zikula\Bundle\CoreBundle\Bundle\MetaData
  */
 private function sync($array)
 {
     // add what is in array but missing from db
     /** @var $metadata MetaData */
     foreach ($array as $name => $metadata) {
         $qb = $this->conn->createQueryBuilder();
         $qb->select('b.id', 'b.bundlename', 'b.bundleclass', 'b.autoload', 'b.bundletype', 'b.bundlestate')->from('bundles', 'b')->where('b.bundlename = :name')->setParameter('name', $name);
         $result = $qb->execute();
         $row = $result->fetch();
         if (!$row) {
             // bundle doesn't exist
             $this->insert($metadata);
         } elseif ($metadata->getClass() != $row['bundleclass'] || serialize($metadata->getAutoload()) != $row['autoload']) {
             // bundle json has been updated
             $updatedMeta = array("bundleclass" => $metadata->getClass(), "autoload" => serialize($metadata->getAutoload()));
             $this->conn->update('bundles', $updatedMeta, array('id' => $row['id']));
         }
     }
     // remove what is in db but missing from array
     $qb = $this->conn->createQueryBuilder();
     $qb->select('b.id', 'b.bundlename', 'b.bundleclass', 'b.autoload', 'b.bundletype', 'b.bundlestate')->from('bundles', 'b');
     $res = $qb->execute();
     foreach ($res->fetchAll() as $row) {
         if (!in_array($row['bundlename'], array_keys($array))) {
             $this->removeById($row['id']);
         }
     }
     // clear the cache
     /** @var $cacheClearer \Zikula\Bundle\CoreBundle\CacheClearer */
     $cacheClearer = \ServiceUtil::getManager()->get('zikula.cache_clearer');
     $cacheClearer->clear('symfony.config');
 }
示例#13
0
文件: Plugin.php 项目: Silwereth/core
 /**
  * Setup the current instance of the Zikula_View class and return it back to the module.
  *
  * @param string       $moduleName Module name.
  * @param string       $pluginName Plugin name.
  * @param integer|null $caching    Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
  * @param string       $cache_id   Cache Id.
  *
  * @return Zikula_View_Plugin instance.
  */
 public static function getPluginInstance($moduleName, $pluginName, $caching = null, $cache_id = null)
 {
     $serviceManager = ServiceUtil::getManager();
     $serviceId = strtolower(sprintf('zikula.renderplugin.%s.%s', $moduleName, $pluginName));
     if (!$serviceManager->has($serviceId)) {
         $view = new self($serviceManager, $moduleName, $pluginName, $caching);
         $serviceManager->set($serviceId, $view);
     } else {
         return $serviceManager->get($serviceId);
     }
     if (!is_null($caching)) {
         $view->caching = $caching;
     }
     if (!is_null($cache_id)) {
         $view->cache_id = $cache_id;
     }
     if ($moduleName === null) {
         $moduleName = $view->toplevelmodule;
     }
     if (!array_key_exists($moduleName, $view->module)) {
         $view->module[$moduleName] = ModUtil::getInfoFromName($moduleName);
         //$instance->modinfo = ModUtil::getInfoFromName($module);
         $view->_addPluginsDir($moduleName);
     }
     // for {gt} template plugin to detect gettext domain
     if ($view->module[$moduleName]['type'] == ModUtil::TYPE_MODULE || $view->module[$moduleName]['type'] == ModUtil::TYPE_SYSTEM) {
         $view->domain = ZLanguage::getModulePluginDomain($view->module[$moduleName]['name'], $view->getPluginName());
     } elseif ($view->module[$moduleName]['type'] == ModUtil::TYPE_CORE) {
         $view->domain = ZLanguage::getSystemPluginDomain($view->getPluginName());
     }
     return $view;
 }
示例#14
0
/**
 * Update operation.
 * @param object $entity The treated object.
 * @param array  $params Additional arguments.
 *
 * @return bool False on failure or true if everything worked well.
 */
function Reviews_operation_update(&$entity, $params)
{
    $dom = ZLanguage::getModuleDomain('Reviews');
    // initialise the result flag
    $result = false;
    $objectType = $entity['_objectType'];
    $currentState = $entity['workflowState'];
    // get attributes read from the workflow
    if (isset($params['nextstate']) && !empty($params['nextstate'])) {
        // assign value to the data object
        $entity['workflowState'] = $params['nextstate'];
        if ($params['nextstate'] == 'archived') {
            // bypass validator (for example an end date could have lost it's "value in future")
            $entity['_bypassValidation'] = true;
        }
    }
    // get entity manager
    $serviceManager = ServiceUtil::getManager();
    $entityManager = $serviceManager->getService('doctrine.entitymanager');
    // save entity data
    try {
        //$this->entityManager->transactional(function($entityManager) {
        $entityManager->persist($entity);
        $entityManager->flush();
        //});
        $result = true;
    } catch (\Exception $e) {
        LogUtil::registerError($e->getMessage());
    }
    // return result of this operation
    return $result;
}
示例#15
0
 /**
 *
 This method is for getting a repository for reviews
 *
 */
 public static function getReviewRepository()
 {
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repository = $entityManager->getRepository('Reviews_Entity_Review');
     return $repository;
 }
示例#16
0
 /**
  * Get manager instance.
  *
  * @param Zikula_Core $core Core instance (optional).
  *
  * @return Zikula_ServiceManager
  */
 public static function getManager(Zikula_Core $core = null)
 {
     if (self::$serviceManager) {
         return self::$serviceManager;
     }
     self::$serviceManager = $core->getServiceManager();
     return self::$serviceManager;
 }
 private function handleLexicon(&$data, $curie, $tempParentID)
 {
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     $data['curie'] = $curie;
     $treeObj = $util->getTreeObj($curie);
     $data['treeObj'] = $treeObj;
     $parentID = $tempParentID;
     if (strcmp($parentID, "none") == 0) {
         $parentID = $util->getParentID($treeObj, $curie);
     }
     $data['parentID'] = $parentID;
     $node = $util->getNode($treeObj, $parentID);
     $data['node'] = $node;
     $mainNode = $util->getNode($treeObj, $curie);
     $data['mainNode'] = $mainNode;
     $list = $util->getChildrenIDs($treeObj, $curie);
     $data['list'] = $list;
     $leafHTML = "";
     $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
     for ($list->rewind(); $list->valid(); $list->next()) {
         $item = $list->current();
         $leaf = $util->getNode($treeObj, $item);
         $leafLinkName = str_replace(" ", "_", $leaf->lbl);
         $leafLinkName = str_replace("(", "_", $leafLinkName);
         $leafLinkName = str_replace(")", "_", $leafLinkName);
         //$leafLink = "/SciCrunchKS/index.php/pages/view/".$leafLinkName;
         $leafLink = "/SciCrunchKS/index.php/pages/view/" . $leaf->id;
         //$leafHTML = $leafHTML . "<ul onlick=\"alert('test');\"><li><span><i class=\"icon-leaf\"></i>" . $leaf->lbl . "</span> <a href=\"".$leafLink."\"><img src=\"/img/view-icon.png\" width=\"25\" height=\"25\"></a></li></ul>\n";
         $leafHTML = $leafHTML . "<ul><li><span id=\"" . $leaf->id . "," . $mainNode->id . "\"><i class=\"icon-plus-sign\"></i>" . $leaf->lbl . "</span> <a href=\"" . $leafLink . "\"><img src=\"/img/view-icon.png\" width=\"25\" height=\"25\"></a></li></ul>\n";
     }
     $data['leafHTML'] = $leafHTML;
 }
/**
 * The zikularoutesmoduleGetListEntry modifier displays the name
 * or names for a given list item.
 *
 * @param string $value      The dropdown value to process.
 * @param string $objectType The treated object type.
 * @param string $fieldName  The list field's name.
 * @param string $delimiter  String used as separator for multiple selections.
 *
 * @return string List item name.
 */
function smarty_modifier_zikularoutesmoduleGetListEntry($value, $objectType = '', $fieldName = '', $delimiter = ', ')
{
    if (empty($value) && $value != '0' || empty($objectType) || empty($fieldName)) {
        return $value;
    }
    $serviceManager = ServiceUtil::getManager();
    $helper = $serviceManager->get('zikularoutesmodule.listentries_helper');
    return $helper->resolve($value, $objectType, $fieldName, $delimiter);
}
示例#19
0
 /**
  * Create a directory below zikula's local cache directory.
  *
  * @param string $dir      The name of the directory to create.
  * @param mixed  $mode     The (UNIX) mode we wish to create the files with.
  * @param bool   $absolute Whether to process the passed dir as an absolute path or not.
  *
  * @return boolean true if successful, false otherwise.
  */
 public static function createLocalDir($dir, $mode = 0777, $absolute = true)
 {
     $path = DataUtil::formatForOS(System::getVar('temp'), true) . '/' . $dir;
     $mode = isset($mode) ? $mode : ServiceUtil::getManager()->getParameter('system.chmod_dir');
     if (!FileUtil::mkdirs($path, $mode, $absolute)) {
         return false;
     }
     return true;
 }
/**
 * The muvideoGetListEntry modifier displays the name
 * or names for a given list item.
 *
 * @param string $value      The dropdown value to process.
 * @param string $objectType The treated object type.
 * @param string $fieldName  The list field's name.
 * @param string $delimiter  String used as separator for multiple selections.
 *
 * @return string List item name.
 */
function smarty_modifier_muvideoGetListEntry($value, $objectType = '', $fieldName = '', $delimiter = ', ')
{
    if (empty($value) || empty($objectType) || empty($fieldName)) {
        return $value;
    }
    $serviceManager = ServiceUtil::getManager();
    $helper = new MUVideo_Util_ListEntries($serviceManager);
    return $helper->resolve($value, $objectType, $fieldName, $delimiter);
}
示例#21
0
 /**
  * Load routes of the specified module from the module's configuration file.
  *
  * @param AbstractBundle $bundle
  *
  * @return RouteCollection[]
  */
 private function find(AbstractBundle $bundle)
 {
     if (!\ServiceUtil::hasContainer()) {
         \ServiceUtil::setContainer($this->container);
     }
     try {
         $path = $this->zikulaKernel->locateResource($bundle->getRoutingConfig());
     } catch (\InvalidArgumentException $e) {
         // Routing file does not exist (e.g. because the bundle could not be located).
         return [new RouteCollection(), new RouteCollection(), new RouteCollection()];
     }
     $name = $bundle->getName();
     $topRouteCollection = new RouteCollection();
     $middleRouteCollection = new RouteCollection();
     $bottomRouteCollection = new RouteCollection();
     /**
      * These are all routes of the module, as loaded by Symfony.
      * @var RouteCollection $routeCollection
      */
     $routeCollection = $this->import($path);
     // Add all resources from the imported route collection to the middleRouteCollection.
     // The actual collection (top, middle, bottom) to add the resources too does not matter,
     // they just must be added to one of them, so that they don't get lost.
     foreach ($routeCollection->getResources() as $resource) {
         $middleRouteCollection->addResource($resource);
     }
     // It would be great to auto-reload routes here if the module version changes or a module is uninstalled.
     // This is not yet possible, see
     // - https://github.com/symfony/symfony/issues/7176
     // - https://github.com/symfony/symfony/pull/15738
     // - https://github.com/symfony/symfony/pull/15692
     // $routeCollection->addResource(new ZikulaResource())
     /** @var Route $route */
     foreach ($routeCollection as $oldRouteName => $route) {
         //          set break here with $oldRouteName == 'zikula_routesmodule_route_renew'
         $this->fixRequirements($route);
         $this->prependBundlePrefix($route, $bundle);
         list($type, $func) = $this->setZikulaDefaults($route, $bundle, $name);
         $routeName = $this->getRouteName($oldRouteName, $name, $type, $func);
         if ($route->hasOption('zkPosition')) {
             switch ($route->getOption('zkPosition')) {
                 case 'top':
                     $topRouteCollection->add($routeName, $route);
                     break;
                 case 'bottom':
                     $bottomRouteCollection->add($routeName, $route);
                     break;
                 default:
                     throw new \RuntimeException('Unknown route position. Got "' . $route->getOption('zkPosition') . '", expected "top" or "bottom"');
             }
         } else {
             $middleRouteCollection->add($routeName, $route);
         }
     }
     return [$middleRouteCollection, $topRouteCollection, $bottomRouteCollection];
 }
示例#22
0
 /**
  * Tree array for jstree
  *
  * @return tree array
  */
 public function getAlbumJsTree()
 {
     $em = \ServiceUtil::getService('doctrine.entitymanager');
     $repository = $em->getRepository('Kaikmedia\\GalleryModule\\Entity\\AlbumEntity');
     $albums = $repository->findAll();
     foreach ($albums as $album) {
         $arrayTree[] = $album->getAsJsTreeArray();
     }
     return $arrayTree;
 }
示例#23
0
/**
 * render plugin for fetching a particular module object
 *
 * Examples
 *   {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
 *   {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
 *   {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  id          Identifier of desired object
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobject($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
    }
    if (!isset($params['assign']) || empty($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $class = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
        // intantiate object model
        $object = new $class();
        $idField = $object->getIDField();
        // assign object data
        // this performs a new database select operation
        // while the result will be saved within the object, we assign it to a local variable for convenience
        $objectData = $object->get(intval($params['id']), $idField);
        if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    } else {
        if ($params['recordClass'] instanceof \Doctrine_Record) {
            $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
            if ($objectData === false) {
                $view->trigger_error(__('Sorry! No such item found.'));
            }
        } else {
            /** @var $em Doctrine\ORM\EntityManager */
            $em = \ServiceUtil::get('doctrine.entitymanager');
            $result = $em->getRepository($params['recordClass'])->find($params['id']);
            $objectData = $result->toArray();
        }
    }
    $view->assign($params['assign'], $objectData);
}
示例#24
0
文件: User.php 项目: rmaiwald/MUBoard
 /**
  * Check for unique values.
  *
  * This method determines if there already exist users with the same user.
  *
  * @param string $fieldName The name of the property to be checked
  * @return boolean result of this check, true if the given user does not already exist
  */
 public function isUniqueValue($fieldName)
 {
     if (empty($this->entity[$fieldName])) {
         return false;
     }
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $repository = $entityManager->getRepository('MUBoard_Entity_User');
     $excludeid = $this->entity['id'];
     return $repository->detectUniqueState($fieldName, $this->entity[$fieldName], $excludeid);
 }
示例#25
0
 /**
  * Get manager instance.
  *
  * @param ContainerBuilder $core ContainerBuilder instance).
  *
  * @return ContainerBuilder
  */
 public static function getManager(ContainerBuilder $container = null)
 {
     if (self::$container) {
         return self::$container;
     }
     if (null === $container) {
         throw new \InvalidArgumentException('No container was specified or previously loaded');
     }
     self::$container = $container;
     return self::$container;
 }
/**
 * The reviewsObjectState modifier displays the name of a given object's workflow state.
 * Examples:
 *    {$item.workflowState|reviewsObjectState}       {* with visual feedback *}
 *    {$item.workflowState|reviewsObjectState:false} {* no ui feedback *}
 *
 * @param string  $state      Name of given workflow state.
 * @param boolean $uiFeedback Whether the output should include some visual feedback about the state.
 *
 * @return string Enriched and translated workflow state ready for display.
 */
function smarty_modifier_reviewsObjectState($state = 'initial', $uiFeedback = true)
{
    $serviceManager = ServiceUtil::getManager();
    $workflowHelper = new Reviews_Util_Workflow($serviceManager);
    $stateInfo = $workflowHelper->getStateInfo($state);
    $result = $stateInfo['text'];
    if ($uiFeedback === true) {
        $result = '<img src="' . System::getBaseUrl() . 'images/icons/extrasmall/' . $stateInfo['ui'] . 'led.png" width="16" height="16" alt="' . $result . '" />&nbsp;&nbsp;' . $result;
    }
    return $result;
}
示例#27
0
 public static function loadModuleAnnotations($entityNamespace, $path)
 {
     /** @var $em EntityManager */
     $em = ServiceUtil::get('doctrine.orm.entity_manager');
     /** @var $ORMConfig Configuration */
     $ORMConfig = $em->getConfiguration();
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(ServiceUtil::get('annotation_reader'), array($path));
     $chain = $ORMConfig->getMetadataDriverImpl();
     // driver chain
     $chain->addDriver($annotationDriver, $entityNamespace);
 }
/**
 * The zikularoutesmoduleObjectState modifier displays the name of a given object's workflow state.
 * Examples:
 *    {$item.workflowState|zikularoutesmoduleObjectState}       {* with visual feedback *}
 *    {$item.workflowState|zikularoutesmoduleObjectState:false} {* no ui feedback *}
 *
 * @param string  $state      Name of given workflow state.
 * @param boolean $uiFeedback Whether the output should include some visual feedback about the state.
 *
 * @return string Enriched and translated workflow state ready for display.
 */
function smarty_modifier_zikularoutesmoduleObjectState($state = 'initial', $uiFeedback = true)
{
    $serviceManager = ServiceUtil::getManager();
    $workflowHelper = $serviceManager->get('zikularoutesmodule.workflow_helper');
    $stateInfo = $workflowHelper->getStateInfo($state);
    $result = $stateInfo['text'];
    if ($uiFeedback === true) {
        $result = '<span class="label label-' . $stateInfo['ui'] . '">' . $result . '</span>';
    }
    return $result;
}
 protected function getService($name)
 {
     if ($name == 'doctrine.entitymanager') {
         return \ServiceUtil::get($name);
     } else {
         if ($name == 'doctrine.connection') {
             return \ServiceUtil::get('doctrine.entitymanager')->getConnection();
         } else {
             return null;
         }
     }
 }
示例#30
0
 /**
  * Get an instance of this class.
  *
  * @return Zikula_View_Resource This instance.
  */
 public static function getInstance()
 {
     $serviceManager = ServiceUtil::getManager();
     $serviceId = 'zikula.viewresource';
     if (!$serviceManager->has($serviceId)) {
         $obj = new self();
         $serviceManager->set($serviceId, $obj);
     } else {
         $obj = $serviceManager->get($serviceId);
     }
     return $obj;
 }