当前位置: 首页>>代码示例>>PHP>>正文


PHP Hooks::notifyAll方法代码示例

本文整理汇总了PHP中Hooks::notifyAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Hooks::notifyAll方法的具体用法?PHP Hooks::notifyAll怎么用?PHP Hooks::notifyAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hooks的用法示例。


在下文中一共展示了Hooks::notifyAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteItem

    /**
     * Deletes a menu item, and all items under it.
     *
     * @param int $id
     * @return bool
     */
    public function deleteItem($id)
    {
        $item = $this->getItem($id);
        // Get all menu item IDs to delete ACL resources and cache later on
        $itemIds = $this->_sql->query('SELECT id, heading_id FROM {PREFIX}mod_menu
											WHERE id = ' . (int) $item['id'] . ' OR heading_id = ' . (int) $item['id'])->fetchAll(PDO::FETCH_ASSOC);
        // Remove all menu items
        $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_menu WHERE id = :id OR heading_id = :id');
        $pdoSt->execute(array(':id' => $item['id']));
        if ($pdoSt->rowCount()) {
            $aclResources = array();
            $cacheKeys = array('menu_items_' . $item['cat_id']);
            foreach ($itemIds as $tmpItem) {
                $aclResources[] = 'menu-item-' . $tmpItem['id'];
                $cacheKeys[] = 'menu_child_items_' . $tmpItem['heading_id'];
            }
            $this->_acl->deleteResource($aclResources);
            $this->_cache->delete($cacheKeys);
            Hooks::notifyAll('menu_delete_item', $item['id'], $item);
            return true;
        } else {
            return false;
        }
    }
开发者ID:jinshana,项目名称:tangocms,代码行数:30,代码来源:menu.php

示例2: delete

 /**
  * Delete
  *  - Delete the given item from a feed
  *    if no item is given, the feed is deleted
  *
  * @param string $id
  * @return bool
  */
 public function delete($id = null)
 {
     if ($this->isRemote) {
         throw new Rss_RemoteFeed();
     }
     if (is_null($id)) {
         if (zula_is_deletable($this->rssDir . $this->name)) {
             // Call hooks
             Hooks::notifyAll('rss_feed_delete', $this->rssDir, $this->name);
             return unlink($this->rssDir . $this->name);
         }
         $this->_log->message('Unable to delete RSS Feed "' . $this->name . '".', LOG::L_WARNING);
         return false;
     }
     $channels = $this->feed->getElementsByTagName('channel');
     if ($channels->length == 0) {
         throw new Rss_NoFeedInfo();
     }
     $channel = $channels->item(0);
     // Find element to delete
     $node = $this->feed->getElementById($id);
     if (is_null($node)) {
         return false;
     }
     $channel->removeChild($node);
     unset($this->items[$id]);
     Hooks::notifyAll('rss_item_delete', $this->name, $id);
     return true;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:37,代码来源:Rss.php

示例3: delete

 /**
  * Deletes 1 or more URL alias by ID
  *
  * @param int|array $alias
  * @return bool
  */
 public function delete($alias)
 {
     $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_aliases WHERE id = ?');
     $delCount = 0;
     foreach ((array) $alias as $id) {
         $pdoSt->execute(array($id));
         if ($pdoSt->rowCount()) {
             ++$delCount;
             Hooks::notifyAll('aliases_delete', (int) $id);
         }
     }
     if ($delCount) {
         $this->_cache->delete('aliases');
         return true;
     } else {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:24,代码来源:aliases.php

示例4: loadController

 /**
  * Loads a specified controller and section if it exists. The resulting
  * output will be returned, a long with the title set by the controller
  * as an array.
  *
  * @param string $cntrlr
  * @param string $sec
  * @param array $config
  * @param string $sector
  * @return array
  */
 public function loadController($cntrlr = 'index', $sec = 'index', array $config = array(), $sector = null)
 {
     $cntrlr = trim($cntrlr) ? $cntrlr : 'index';
     $sec = trim($sec) ? $sec : 'index';
     // Ensure no other controller/module is being loaded currently
     $this->_log->message(sprintf('attempting to load controller "%s::%s::%s"', $this->name, $cntrlr, $sec), Log::L_DEBUG);
     if (self::$currentMcs !== false) {
         throw new Module_UnableToLoad('unable to load new module, a module is already loading');
     } else {
         if ($this->disabled === true) {
             $lMsg = 'unable to load controller, parent module "' . $this->name . '" is currently disabled';
             $this->_log->message($lMsg, Log::L_NOTICE);
             throw new Module_Disabled($lMsg);
         } else {
             if (_ACL_ENABLED) {
                 $resource = $this->name . '_global';
                 if (!$this->_acl->check($resource)) {
                     throw new Module_NoPermission($resource);
                 }
             }
         }
     }
     if (!$this->controllerExists($cntrlr)) {
         throw new Module_ControllerNoExist('controller "' . $cntrlr . '" does not exist');
     }
     /**
      * Create some details for the controller, create a new
      * instance of it and identify it with the details needed.
      */
     $class = $this->name . '_controller_' . $cntrlr;
     $method = $sec . 'Section';
     try {
         self::$currentCntrlrObj = new $class($this->getDetails(), $config, $sector);
         if (self::$currentCntrlrObj instanceof Zula_ControllerBase) {
             if (!is_callable(array(self::$currentCntrlrObj, $method), false, $callableName)) {
                 throw new Module_ControllerNoExist('controller section/method "' . $callableName . '" is not callable');
             }
             // Store MCS details
             self::$currentMcs = array('module' => $this->name, 'cntrlr' => $cntrlr, 'section' => $sec);
             $details = array('cntrlr' => self::$currentCntrlrObj, 'ident' => $this->name . '::' . $cntrlr . '::' . $sec, 'output' => self::$currentCntrlrObj->{$method}(), 'outputType' => self::$currentCntrlrObj->getOutputType(), 'title' => self::$currentCntrlrObj->getTitle());
             /**
              * Trigger output hooks. Listeners should return a string with the
              * html they want to add to the controllers output.
              */
             if (!is_bool($details['output'])) {
                 $ota = Hooks::notifyAll('module_output_top', self::getLoading(), $details['outputType'], $sector, $details['title']);
                 $outputTop = count($ota) > 0 ? implode("\n", $ota) : '';
                 $oba = Hooks::notifyAll('module_output_bottom', self::getLoading(), $details['outputType'], $sector, $details['title']);
                 $outputBottom = count($oba) > 0 ? implode("\n", $oba) : '';
                 $details['output'] = $outputTop . $details['output'] . $outputBottom;
             }
             Hooks::notifyAll('module_controller_loaded', self::getLoading(), $details['outputType'], $sector, $details['title']);
             // Reset MCS details and restore i18n domain
             self::$currentMcs = false;
             self::$currentCntrlrObj = false;
             $this->_i18n->textDomain(I18n::_DTD);
             return $details;
         } else {
             throw new Module_ControllerNoExist('controller "' . $class . '" must extend Zula_ControllerBase');
         }
     } catch (Exception $e) {
         // Catch any exceptions throw to reset the MCS details, then re-throw
         $this->_i18n->textDomain(I18n::_DTD);
         self::$currentMcs = false;
         self::$currentCntrlrObj = false;
         throw $e;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:79,代码来源:Module.php

示例5: purge

 /**
  * Purge all cache files
  *
  * @return bool
  */
 public function purge()
 {
     try {
         foreach (new DirectoryIterator($this->cacheDir) as $file) {
             if (!$file->isDot() && strpos($file->getFilename(), '.') !== 0) {
                 unlink($file->getPathname());
             }
         }
         Hooks::notifyAll('cache_purge', 'file');
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:19,代码来源:File.php

示例6: delete

 /**
  * Removes a page and all children under it, by ID
  *
  * @param int $pid
  * @return int
  */
 public function delete($pid)
 {
     $page = $this->getPage($pid);
     // Get all of the IDs of pages to delete
     $pageIds = array($page['id']);
     foreach ($this->getChildren($page['id'], true, array(), false) as $child) {
         $pageIds[] = $child['id'];
     }
     // Remove the needed ACL resources and SQL entries
     $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_page WHERE id = ?');
     $aclResources = array();
     $delCount = 0;
     foreach ($pageIds as $id) {
         $pdoSt->execute(array($id));
         if ($pdoSt->rowCount()) {
             $aclResources[] = 'page-view_' . $id;
             $aclResources[] = 'page-edit_' . $id;
             $aclResources[] = 'page-manage_' . $id;
             ++$delCount;
         }
     }
     $pdoSt->closeCursor();
     $this->_acl->deleteResource($aclResources);
     Hooks::notifyAll('page_delete', $delCount, $pageIds);
     return $delCount;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:32,代码来源:page.php

示例7: make

 /**
  * Builds up a string request path to be used
  *
  * @param string $separator
  * @param string $type
  * @param bool $noBase
  * @return string
  */
 public function make($separator = '&', $type = null, $noBase = false)
 {
     $data = array();
     foreach ($this->parsed as $key => $val) {
         if ($key == 'arguments' || $key == 'siteType' && $val == $this->_router->getDefaultSiteType()) {
             continue;
         } else {
             if ($key != 'siteType' && $val == null) {
                 $val = 'index';
             }
         }
         $data[$key] = $val;
     }
     $arguments = $this->parsed['arguments'];
     $argString = '';
     if (empty($arguments)) {
         // No need to keep empty parts on
         while (end($data) == 'index') {
             array_pop($data);
         }
     } else {
         foreach ($arguments as $key => $val) {
             $argString .= '/' . $key . '/' . $val;
         }
     }
     $requestPath = trim(implode('/', $data), '/') . $argString;
     # hook event: router_make_url
     $tmpRp = Hooks::notifyAll('router_make_url', $requestPath);
     if (is_array($tmpRp)) {
         $requestPath = trim(end($tmpRp), '/');
     }
     $requestPath = zula_htmlspecialchars($requestPath);
     // Create the correct URL based upon router type
     if (!$type) {
         $type = $this->_router->getType();
     }
     unset($this->queryStringArgs['url']);
     if ($type == 'standard') {
         // Add in the 'url' query string needed, force it to be first index
         if ($requestPath) {
             $this->queryStringArgs = array_merge(array('url' => $requestPath), $this->queryStringArgs);
         }
         if ($this->_input->has('get', 'ns')) {
             $this->queryStringArgs['ns'] = '';
         }
         $url = $noBase ? 'index.php' : _BASE_DIR . 'index.php';
     } else {
         $url = $noBase ? $requestPath : _BASE_DIR . $requestPath;
     }
     if (!empty($this->queryStringArgs)) {
         $url .= '?' . str_replace('%2F', '/', http_build_query($this->queryStringArgs, null, $separator));
     }
     return $this->fragment ? $url . '#' . $this->fragment : $url;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:62,代码来源:Url.php

示例8: deletePart

 /**
  * Delete an article part of an article if it exists
  *
  * @param int $pid
  * @return bool
  */
 public function deletePart($pid)
 {
     $part = $this->getPart($pid);
     $query = $this->_sql->query('DELETE FROM {PREFIX}mod_article_parts WHERE id = ' . (int) $part['id']);
     $query->closeCursor();
     if ($query->rowCount() > 0) {
         Hooks::notifyAll('article_delete_part', $part['id'], $part);
         return true;
     } else {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:18,代码来源:article.php

示例9: deleteUser

    /**
     * Deletes a user and all meta data related to it
     *
     * @param int $uid
     * @return bool
     */
    public function deleteUser($uid)
    {
        $user = $this->getUser($uid);
        if ($user['id'] == self::_ROOT_ID || $user['id'] == self::_GUEST_ID) {
            throw new Ugmanager_InvalidUser('root or guest user can not be deleted');
        }
        $result = $this->_sql->exec('DELETE u, m FROM {PREFIX}users AS u
											LEFT JOIN {PREFIX}users_meta AS m ON m.uid = u.id
											WHERE u.id = ' . (int) $user['id']);
        if ($result) {
            if (isset($this->userCount['*'])) {
                --$this->userCount['*'];
            }
            if (isset($this->userCount[$user['group']])) {
                --$this->userCount[$user['group']];
            }
            $this->_cache->delete('ugmanager_users');
            Hooks::notifyAll('ugmanager_user_delete', $user);
            return true;
        } else {
            return false;
        }
    }
开发者ID:jinshana,项目名称:tangocms,代码行数:29,代码来源:Ugmanager.php

示例10: purge

 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', 'disabled');
     return true;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:10,代码来源:Disabled.php

示例11: setContentUrl

 /**
  * Sets the content URL that this form is adding/editing
  *
  * @param string $url
  * @return bool
  */
 public function setContentUrl($url)
 {
     $this->contentUrl = (string) $url;
     Hooks::notifyAll('view_form_set_content_url', Module::getLoading(), $url);
     return true;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:12,代码来源:Form.php

示例12: editController

 /**
  * Edit details of an existing controller. The 'mod' value can never change
  * by this method.
  *
  * @param int $id
  * @param array $details
  * @return bool
  */
 public function editController($id, array $details)
 {
     $cntrlr = $this->getControllerDetails($id);
     $details['mod'] = $cntrlr['mod'];
     if (empty($details['sector'])) {
         $details['sector'] = $cntrlr['sector'];
     }
     if ($this->detachController($id)) {
         $this->addController($details['sector'], $details, $id);
         Hooks::notifyAll('layout_edit_cntrlr', $id, $details);
         return $id;
     } else {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:23,代码来源:Layout.php

示例13: modeConfigSection

 /**
  * Gets the display mode configuration details from the hooks
  * of the correct module.
  *
  * @return string|bool
  */
 public function modeConfigSection()
 {
     try {
         $hook = $this->_router->getArgument('module') . '_display_mode_config';
         $data = Hooks::notifyAll($hook, $this->_router->getArgument('mode'));
         return $data ? implode("\n", $data) : false;
     } catch (Router_ArgNoExist $e) {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:16,代码来源:edit.php

示例14: hookCntrlrPreDispatch

 /**
  * Add in the right RSS feed to the HTML head
  *
  * @param array $rData
  * @return array
  */
 public function hookCntrlrPreDispatch($rData)
 {
     if (Registry::has('theme')) {
         if ($rData['module'] != 'rss' && $rData['controller'] != 'feed') {
             // Get the default feed
             try {
                 $defFeed = array();
                 $defFeed[] = $this->_config->get('rss/default_feed');
                 if (!Rss::feedExists($defFeed[0])) {
                     unset($defFeed[0]);
                 }
             } catch (Config_KeyNoExist $e) {
                 $this->_log->message('RSS config key "rss/default_feed" does not exist, unable to add default feed to head.', Log::L_WARNING);
             }
             // Find all the RSS feeds for the current page
             $feeds = Hooks::notifyAll('rss_insert_head', $rData['module'], $rData['controller'], $rData['section']);
             if (is_array($feeds)) {
                 foreach (array_filter(array_merge($defFeed, $feeds)) as $feed) {
                     // Add all found feeds to head
                     $rss = new Rss($feed);
                     if ($rss->hasFeedInfo()) {
                         $details = array('rel' => 'alternate', 'type' => 'application/rss+xml', 'href' => $this->_router->makeFullUrl('rss', 'feed', $feed), 'title' => $rss->getFeedInfo('title'));
                         $this->_theme->addHead('link', $details);
                     } else {
                         $this->_log->message('Feed "' . $feed . '" does not have feed info set.', Log::L_WARNING);
                     }
                 }
             }
         }
     }
     return $rData;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:38,代码来源:listeners.php

示例15: purge

 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', null);
     return true;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:10,代码来源:Base.php


注:本文中的Hooks::notifyAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。